Display only a part of jpg without cropping the actual file

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Display only a part of jpg without cropping the actual file

Post by Bonzo »

You would have to save this ( untested code ) as a file on its own and call from the page with <img src="code.php">

Code: Select all

<?php
$cmd = "convert image.jpg -gravity Center -crop 100x100+0+0  JPG:-";

header("Content-type: image/jpeg");
passthru($cmd, $retval);
?>
As to doing it without IM, I assume you could do it with Javascript
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Display only a part of jpg without cropping the actual file

Post by anthony »

If you are not doing this for the web, but for a X window display use...

convert image -crop ???? miff:- | display

I very often use this to look at the results of various transformations, debugging, and trial and error option determination, without saving the resultingj image to disk.

See IM Examples, Basics, Display and Animate
http://imagemagick.org/Usage/basics/#display
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Display only a part of jpg without cropping the actual file

Post by fmw42 »

this also works

display logo:[256x256+256+128]
Post Reply