Page 1 of 1
what does jpg:- do?
Posted: 2012-01-16T22:48:21-07:00
by james438
Hi,
I am pretty new here, so please let me know if I am posting in the wrong place.
I am also new to ImageMagick as well and am casually trying to learn some of the basics. In the following example what does
jpg:- do?
Code: Select all
<?php
header( 'Content-Type: image/jpg' );
system("convert images/pops/gdsample1.jpg -flop jpg:-");
?>
Re: what does jpg:- do?
Posted: 2012-01-17T10:33:49-07:00
by fmw42
It sends a jpg file to standard output (generally so that it can be piped to standard input to be processed by some other convert statement or some non-IM tool). You would be better creating a saved file with a given name.
Re: what does jpg:- do?
Posted: 2012-01-17T13:09:58-07:00
by Bonzo
I can not remember if -flop is mirror in x axis or y axis. The code you have will mirror the photo in one axis and then display without saving it.
Re: what does jpg:- do?
Posted: 2012-01-17T13:24:49-07:00
by james438
Ah, thank you. It was my suspicion that ":-" would somehow stop any permanent changes from being made, such as by using the "-write" command.
Re: what does jpg:- do?
Posted: 2012-01-17T17:09:22-07:00
by fmw42
You do not need to use -write to save an output image
convert image.jpg -flop result.jpg
will do fine, by just specifying a filename and suffix.
Use -write to save intermediate images or multiple output images, except for the last image.
Re: what does jpg:- do?
Posted: 2012-01-18T07:30:36-07:00
by james438
Thank you, -write makes more sense now. I had been thinking of ImageMagick operating more like css. I still have one more question about my initial script though. What does the ending colon and dash located right before the closing quote do?
Thanks again for your explanations.
Re: what does jpg:- do?
Posted: 2012-01-18T12:37:08-07:00
by fmw42
jpg:-
In your command this says to send a jpg format image (that is the jpg:) to standard output (that is the -) without writing the file to disk.
Re: what does jpg:- do?
Posted: 2012-01-18T15:02:40-07:00
by james438
Awesome, thanks

Re: what does jpg:- do?
Posted: 2012-01-19T10:27:12-07:00
by Bonzo
Out of interest you are not using MagickWand for php but you are using the command line. I would post in the users section next time.
Re: what does jpg:- do?
Posted: 2012-01-20T18:10:05-07:00
by anthony
james438 wrote:Hi,
I am pretty new here, so please let me know if I am posting in the wrong place.
I am also new to ImageMagick as well and am casually trying to learn some of the basics. In the following example what does
jpg:- do?
Code: Select all
<?php
header( 'Content-Type: image/jpg' );
system("convert images/pops/gdsample1.jpg -flop jpg:-");
?>
In your specific case this PHP, outputs a bare minimum HTTP protocol header, followed but the image that the header indicates folows. This is typically run by the web server (like apache), which may add extra header items, then pass it to the client.
In other words calling the PHP script via a web client/browser, returns a JPG image, regardless of the image source format (though it is JPEG in this case), any extra modifications (-flop), and without needing a temprary file, or any save of the modified image to disk on the web server machine (client browsers would probably save it).
A good addition to this PHP script may be the inclusion of a 'timestamp' in the header based on the source image file timestamp (and the scripts own time stamp, whatever is newer), as the destination image will not change unless the source image or script changes. This prevents client browsers for needing to 'reload' the image when they already have a valid copy that does not change. Saves a lot of extra traffic and work on the both client and server machines!