How do I crop an image from a blank area
How do I crop an image from a blank area
In A,The shaded portion of the picture represents an image,the blue dotted box indicates the area I want to crop.
I want a picture like B,the white space is transparent,But I can only get a picture of what C looks like,image pixels are always filled from the top.
The command I'm using looks something like this:
convert 32.jpg -crop 356x768+436+263 -background transparent -extent 356x768 output.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How do I crop an image from a blank area
I think you want the output to contain part of the input, plus some extra pixels that are transparent. You have a positive y-offset "+263" but your diagrams suggest you want a negative offset. I would use virtual pixels and a viewport, like this:
Code: Select all
magick in.png -set option:distort:viewport 400x400+100-100 -virtual-pixel None -distort SRT 1,0 +repage out.png
snibgo's IM pages: im.snibgo.com
Re: How do I crop an image from a blank area
Yeah, I'm using a negative y-offset,posted in a hurry,so a random copy of the previous test command.
I tried your command and it worked fine.Thank you very much!!
I would like to ask you another question.
I use the following command to round the corners of the picture.
If the picture is like C, i hope that only the upper left corner is rounded, but now all the four corners of the shaded part will be rounded.
How to don't ignore alpha channel when rounding corners?
Thanks again!
(In fact, I don't really understand those parameters,catch up with project schedule,you know...)
I tried your command and it worked fine.Thank you very much!!
I would like to ask you another question.
I use the following command to round the corners of the picture.
Code: Select all
convert cut3.png -alpha set -virtual-pixel transparent -channel A -blur 0x32 -threshold 50% +channel cut4.png
How to don't ignore alpha channel when rounding corners?
Thanks again!
(In fact, I don't really understand those parameters,catch up with project schedule,you know...)
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: How do I crop an image from a blank area
A great method was provided already by snibgo. You can also use "-extent" to get essentially the same result. You can cut out a portion of an input image and place it in a particular location on a certain size transparent canvas with a command like this...disburden wrote: ↑2019-08-08T11:19:44-07:00In A,The shaded portion of the picture represents an image,the blue dotted box indicates the area I want to crop.
I want a picture like B,the white space is transparent,But I can only get a picture of what C looks like,image pixels are always filled from the top.
Code: Select all
convert input.png -background none -extent 720x720+320-90 result.png