Embedded jpg from remote raw file, only?

307 Views Asked by At

Lets say I have a RAW-image on a remote server, like this www.mydomain.com/DSC0001.ARW, and I would like to only extract the "small" preview image (jpg) from that raw file, without having to download the whole raw-file, is that possible somehow?

2

There are 2 best solutions below

10
On BEST ANSWER

Updated Again

Ok, it appears that the server on which you have the raw files is not actually yours, so you cannot extract the preview image on the server as I suggested... however, you can download just a part of the 25MB image and then extract locally. So, here I download just the first 1MB from a file on a server I don't own onto my local machine and then extract the preview locally:

curl -r 0-1000000 http://www.rawsamples.ch/raws/sony/RAW_SONY_ILCA-77M2.ARW > partial.arw
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  976k  100  976k    0     0   984k      0 --:--:-- --:--:-- --:--:--  983k

exiftool -b -PreviewImage -W! preview.jpg partial.arw

You may need to experiment with how much of the file you need to download, depending on the camera and its settings etc.

Updated Answer

Actually, it is easier to use exiftool to extract the preview on the server as (being just a Perl script) it is miles simpler to install than ImageMagick.

Here is how to extract the Preview from a Sony ARW file at the command line:

exiftool -b -PreviewImage -W! preview.jpg sample.arw

That will extract the Preview from sample.arw into a file called preview.jpg.

So, you would put a PHP script on your server (naming it preview.php) that looks like this:

#!/usr/bin/php -f
<?php
$image=$_GET['image'];
header("Content-type: image/jpeg");
exec("exiftool -b -PreviewImage -W! preview.jpg $image");
readfile("preview.jpg");
?>

and it will extract the Preview from the parameter named image and send it back to you as a JPEG.

Depending on your server setup and file naming, the invocation will be something like:

http://yourserver/preview.php?image=sample.arw

Note that you will need to do a little more work if the server is multi-user because as it is I have fixed the name of the preview file as preview.jpg which means two simultaneous users could potentially clash.

Original Answer

That's quite easy if you can run ImageMagick on your server, you could run a little PHP script that takes the image name as a parameter, extracts the thumbnail and sends you a JPEG.

I presume you mean a Sony Alpha raw image.

2
On

Let me preface this with: I am no image processing expert.

Answer to your question

You can show images resized, but this will still download the entire file. To my mind, that means the best approach would be to save a pre-processed thumbnail of that image alongside the raw image. If you use some naming convention like DSC0001.ARW.thumbnail.png, they should be easy to find.

Possible alternative solution on the AWS stack

Probably only a realistic solution if you are willing to get involved with some code and AWS. If you use AWS S3 for storing your images, you could fire an event off to AWS Lambda to run a script which processes your raw file into the thumbnail and save that to S3 for you; whenever you upload a new raw file.