如何使用命令行PHP程序查看jpg图像
有没有办法在命令行PHP中查看jpg图像 我想在一个命令行PHP程序中循环浏览一个照片目录,并通过使用PHP stdin来使用击键对该照片执行操作,比如将其移动到另一个目录。我无法找到从命令行PHP输出每个图像的方法 谢谢 这是我到目前为止的代码。如果我能看到jpg,我想我会没事的如何使用命令行PHP程序查看jpg图像,php,view,command,line,jpeg,Php,View,Command,Line,Jpeg,有没有办法在命令行PHP中查看jpg图像 我想在一个命令行PHP程序中循环浏览一个照片目录,并通过使用PHP stdin来使用击键对该照片执行操作,比如将其移动到另一个目录。我无法找到从命令行PHP输出每个图像的方法 谢谢 这是我到目前为止的代码。如果我能看到jpg,我想我会没事的 <?php // View the jpg images one at a time $files = glob("images/*.jpg"); foreach($files as $jpg){ //
<?php
// View the jpg images one at a time
$files = glob("images/*.jpg");
foreach($files as $jpg){
// echo "<img src='$jpg'></br>";
echo "view image somehow" . PHP_EOL;
echo "The jpg variable equals '$jpg'" . PHP_EOL;
// show them a message to enter letter for category
echo "Enter the category, a(family), r(friends), c(coworkers), d(delete), ctrl-letter(two folders)" . PHP_EOL;
// the script will wait here until the user has entered something and hit ENTER
$category = read_stdin();
// This will display the category message including the category they entered.
echo "You chose $category . Next photo" . PHP_EOL;
switch ($category) {
case "a":
echo "$category equals family" . PHP_EOL;
r ename("$jpg", "images/sorted/family/$jpg");
break;
case "r":
echo "$category equals friends" . PHP_EOL;
rename("$jpg", "images/sorted/friends/$jpg");
break;
case "c":
echo "$category equals coworkers" . PHP_EOL;
rename("$jpg", "images/sorted/coworkers/$jpg");
break;
default:
echo "$category is not equal to a,r, or c" . PHP_EOL;
}
}
// our function to read from the command line
function read_stdin()
{
$fr=fopen("php://stdin","r"); // open our file pointer to read from stdin
$input = fgets($fr,128); // read a maximum of 128 characters
$input = rtrim($input); // trim any trailing spaces.
fclose ($fr); // close the file handle
return $input; // return the text entered
}
?>
你给我发了一封关于ImageMagick“显示”的邮件
您可以在后台运行“display”,然后使用“-remote”将图片和更新发送到display。我在Linux下使用shell脚本完成了这项工作,尽管我认为“显示”在Windows上的工作方式不同
有关各种图像程序的远程控制的一些想法,请参阅我的原始说明(仅适用于linux)
我最后使用了“打开”命令,在“预览”中打开图像
看起来“QLManager”也可能是一个选项。我无法让ImageMagick工作。它似乎需要安装X11,而在最近的几个版本中,它还没有包含在OSX中。苹果的支持页面指向“xquartz”作为在OS X上安装X11的站点。我安装了它,但在与它的设置和Imagemagick进行斗争后,四处查看,发现“打开”。谢谢如果你使用php,你会像制作网页一样使用它。什么操作系统?在windows中,%路径%中的任何图像查看器都可以工作,例如mspaint\PATH\to\image.jpg
将从命令行启动绘图它将从桌面在windows 7系统和OSX系统上运行。希望如此。是否有一个适用于CLI PHP的图像查看器可以在OS X和Windows中工作?