duanjiu6697 2014-05-30 00:39
浏览 262

将RAW转换为JPEG(尝试使用)ImageMagick

I do not care if a solution that converts RAW to JPEGs uses ImageMagick or not, it just appeared to be the most doucmented, so I started there.

I have had success converting a JPEG to a different sized JPEG, but have been unable to convert a RAW to a JPEG. After looking at Convert RAW photos to JPEG in linux/php, I tried that code:

try {
    $im = new Imagick($inputURL);
    $im->setimageformat("jpg");
    $im->writeimage($outputURL);
    $im->clear();
    $im->destroy();
} catch (Exception $e) {
    echo $e;
}

and received this error:

exception 'ImagickException' with message 'unable to open image `/tmp/magick-XXaana6Q.ppm': No such file or directory @ blob.c/OpenBlob/2480' in /UPSTREAM/public_html/core/functions.php:116 Stack trace: #0 /UPSTREAM/public_html/core/functions.php(116): Imagick->__construct('/UPSTREAM/p...') #1 /UPSTREAM/public_html/core/functions.php(129): resizeImage('/UPSTREAM/p...', '/UPSTREAM/p...', Array) #2 {main}

I then tried:

exec("/usr/bin/convert -define jpeg:size=1280x720 {$inputURL} {$outputURL}");

based on the same post near the bottom, but it is not producing any file.

Then I tried raw to JPEG conversion, but I haven't had any luck with that code either. Then I modified it with Convert PDF to JPEG with PHP and ImageMagick to no avail (EDIT: I got a similar error to the one above):

try {
    $im = new Imagick();
    $im->setResolution(300,300);
    $im->readimage($inputURL); 
    $im->setimageformat("jpg");
    $im->writeimage($outputURL);
    $im->clear();
    $im->destroy();
} catch (Exception $e) {
    echo $e;
}

For kicks, these are variations that I've tried:

//echo "/usr/bin/convert {$inputURL} -resize {$dimensions[0]}x{$dimensions[1]} {$outputURL}";
#phpinfo();
#exec("/usr/bin/convert {$inputURL} -resize {$dimensions[0]}x{$dimensions[1]} {$outputURL}");
#exec("/usr/bin/convert {$inputURL} -define {$dimensions[0]}x{$dimensions[1]} {$outputURL}");
#exec("/usr/bin/convert -resize {$dimensions[0]}x{$dimensions[1]} rgb:{$inputURL} {$outputURL}");
#exec("/usr/bin/convert -define jpeg:size=1280x720 {$inputURL} {$outputURL}");

(Potentially) Pertinent Details:

  • I am using WebHostingHub as my host so the /usr/bin/convert is their equivalent to the convert.
  • (EDIT) I am using a Sony camera, such that all of my RAW files will contain a .ARW extension
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大