Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert RAW photos to JPEG in linux/php

I'm working on an photo upload app and need to allow users to upload raw files from cameras (these are not jpegs) and have the server automatically create a jpeg version of them. I currently have Imagemagick installed but I don't think there is a way to do it in there.

Cameras come out with new raw formats all the time, so im looking for something that will be relativley up-to-date and command php exec() is an option too.

Does anyone have anything to suggestion for raw conversion?

like image 739
David Avatar asked May 11 '12 20:05

David


People also ask

How do I convert RAW images to JPEG?

Convert your file Open the photos in RAW format, e.g. in Photoshop. Go to 'File' and choose 'Save As' and select from the list '. jpg' (it might appear as JPEG). Choose a compression between 90-100%, otherwise this leads to loss of quality.

Can GIMP export raw?

No. In order to work with images you shot in a RAW format in GIMP, you'll need a RAW converter to first change them to something that GIMP can read, like TIFF or JPG.

How do I convert a RAW file?

To convert a RAW file to a JPEG image file, open your RAW file in your chosen editing software. From there, simply make a copy of the file, save, and export it as a new JPEG image file. You'll then have two files — the original RAW file and the converted JPEG image.


2 Answers

Actually, as you can see in this list, ImageMagick does support RAW photos: http://www.imagemagick.org/script/formats.php (e.g. .NEF nikon photos and .CR2 canon photos).

Example code for a .CR2 photo:

$im = new Imagick( 'source.CR2' );
$im->setImageFormat( 'jpg' );
$im->writeImage( 'result.jpg' );
$im->clear();
$im->destroy();
like image 174
Jeroen Avatar answered Sep 22 '22 12:09

Jeroen


Even easier to

sudo apt-get install ufraw ufraw-batch

then either use UFRaw (see man pages) or use ImageMagick which uses UFRaw

convert mypic.RAF mypic.jpeg
like image 32
Keir Avatar answered Sep 21 '22 12:09

Keir