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 theconvert
. -
(EDIT) I am using a Sony camera, such that all of my RAW files will contain a
.ARW
extension