How do I squish part of an image?

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
wxguy
Posts: 4
Joined: 2015-10-27T16:18:52-07:00
Authentication code: 1151

How do I squish part of an image?

Post by wxguy »

My apologies for lack of correct terminology... I am seeking assistance on how to adjust the size of part of an image. I want the bottom half of an image (.jpg) to remain the same, while resizing the Y-axis (height) of the top half of the image. (I am trying to adjust a satellite image so it overlays nicely in Google maps-adjusting for earth's curvature). Any assistance would be greatly appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How do I squish part of an image?

Post by fmw42 »

What platform are you on? What version of Imagemagick? Please always provide that information. See viewtopic.php?f=1&t=9620

If on Unix, then try

Code: Select all

convert image.jpg -crop 100x50% \
\( -clone 0 -resize 100x150% \) \
-delete 0 +swap -append result.jpg
On Windows, try

Code: Select all

convert image.jpg -crop 100x50% ^
( -clone 0 -resize 100x150% ) ^
-delete 0 +swap -append result.jpg
First line crops in two equal vertical pieces.
Second line copies the top part and resize vertically by 150%
Third line removes the original top part and swaps the original bottom and new top and appends them to make the output


See
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/basics/#clone
http://www.imagemagick.org/Usage/crop/#crop_tile
http://www.imagemagick.org/Usage/resize/
http://www.imagemagick.org/Usage/layers/#append
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: How do I squish part of an image?

Post by glennrp »

Have a look at the "-distort" option.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How do I squish part of an image?

Post by fmw42 »

glennrp wrote:Have a look at the "-distort" option.
Following up on the above.

You could use -distort Polynomial to a second or third order polynomial warping by picking control points on the appropriate map (projection) and finding corresponding points on the image. See http://www.imagemagick.org/Usage/distorts/#polynomial
wxguy
Posts: 4
Joined: 2015-10-27T16:18:52-07:00
Authentication code: 1151

Re: How do I squish part of an image?

Post by wxguy »

fmw42, thank you for pointing me in the right direction. I am on Unix and ImageMagick 6.7.2-7. I'll attempt your suggestions :)
wxguy
Posts: 4
Joined: 2015-10-27T16:18:52-07:00
Authentication code: 1151

Re: How do I squish part of an image?

Post by wxguy »

Glennrp thank you for the suggestion. fmw42... the control points actually sound like a very useful way of tackling my problem. Thank you!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How do I squish part of an image?

Post by fmw42 »

IM 6.7.2.7 is ancient. About 200 versions old. I would suggest you upgrade if you can.
wxguy
Posts: 4
Joined: 2015-10-27T16:18:52-07:00
Authentication code: 1151

Re: How do I squish part of an image?

Post by wxguy »

fmw42, the crop and resize -append works like a charm! I will have to learn more about this great tool.Thank you so much!
Post Reply