Crop image keeping original position

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
tester
Posts: 2
Joined: 2019-09-30T10:52:39-07:00
Authentication code: 1152

Crop image keeping original position

Post by tester »

Hi!!

Having
Image
https://upload.wikimedia.org/wikipedia/ ... go.svg.png

I would like to cut the lion but keep the original image size and lion in place.

right now i'm only able to cut the lion and keep the original image size, but not lion's position:

Code: Select all

convert /tmp/stratton.png -crop 550x800+320+30 -background none  -extent 1200x1920 /tmp/output.png
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Crop image keeping original position

Post by snibgo »

I'm not sure what you want. After crop, the image has an offset in a canvas, so we can flatten to use that entire canvas if we want:

Code: Select all

magick 1200px-Stratton_Oakmont_logo_svg.png -crop 550x800+320+30 -background Blue -layers Flatten x.png
Is that what you want?
snibgo's IM pages: im.snibgo.com
tester
Posts: 2
Joined: 2019-09-30T10:52:39-07:00
Authentication code: 1152

Re: Crop image keeping original position

Post by tester »

Yes! That's exactly what i wanted!
I will have to read more about what layers does. ty!

This is my final code! :P

Code: Select all

 convert /tmp/stratton.png -crop 550x800+320+30 -background none -layers Flatten /tmp/lion.png

 convert /tmp/stratton.png -crop 250x800+320+300 -background none -layers Flatten /tmp/title.png

convert /tmp/lion.png /tmp/title.png  -background none -layers Flatten /tmp/final.png
Post Reply