cutting the height images by percent size

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
jmishal
Posts: 3
Joined: 2016-01-04T08:22:06-07:00
Authentication code: 1151

cutting the height images by percent size

Post by jmishal »

ok ,, cutting the height images by percent size

assume i have multiples images size like
1600x1200 1200x1600 640x640 960x960 2448x3264 640x614 640x640 2448x3264 2896x2896 2448x3264 750x1334 900x1600 750x1334.. etc

all those images have logo in the right bottom near to corner (( see the below example pic have asterisk as logo ))

Image

so I need to cutting 'height' only from button by percent size like (10%) to remove the logo

or any best way to identify the logo and replace it either another logo nor black bar.

I already make bash script to identify the image size with if statement


thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: cutting the height images by percent size

Post by fmw42 »

See IM function -crop. It allows percents on the image size. http://www.imagemagick.org/Usage/crop/#crop_percent.

Always best to provide your IM version and platform when asking questions. See viewtopic.php?f=1&t=9620

You can also just use -draw to paint over that area with some fixed color. See http://www.imagemagick.org/Usage/draw/#primitives

Or you could crop out a section of the image somewhere else and composite it over the star or logo. See http://www.imagemagick.org/Usage/compose/#compose and http://www.imagemagick.org/Usage/layers/#convert.

Or you could get some inpainting software to fill in that area with similar texture. On Windows, see http://im.snibgo.com/fillholespri.htm and http://im.snibgo.com/fillholes.htm or use an online inpaint tool such as at http://www.webinpaint.com/
jmishal
Posts: 3
Joined: 2016-01-04T08:22:06-07:00
Authentication code: 1151

Re: cutting the height images by percent size

Post by jmishal »

fmw42 wrote:See IM function -crop. It allows percents on the image size. http://www.imagemagick.org/Usage/crop/#crop_percent.

Always best to provide your IM version and platform when asking questions. See viewtopic.php?f=1&t=9620
still not got the answer of my question ,,
I try deference ways to run -crop with convert but still doesn't work ..

Code: Select all

convert 1455.jpg -crop 1200x95%+0+0 out.png 
above code almost near what i need but the output is something like ((zoom in)) the image not cutting from down



the expect the output like that

Image



btw: I've always read the instruction & see the examples ... before post question either here or any other place & i also googled but not found my answer... but in the mean time I wonder why they're support sites (like here) isn't to provide support and provide help to clients?
be-note that not every one can understood the coding or how things work from the first time.

thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: cutting the height images by percent size

Post by snibgo »

"%" means both width and height are percentages. You could use:

Code: Select all

convert in.jpg -crop 100x95%+0+0 +repage out.png
snibgo's IM pages: im.snibgo.com
jmishal
Posts: 3
Joined: 2016-01-04T08:22:06-07:00
Authentication code: 1151

Re: cutting the height images by percent size

Post by jmishal »

snibgo wrote:"%" means both width and height are percentages. You could use:

Code: Select all

convert in.jpg -crop 100x95%+0+0 +repage out.png


Works like a charm, thanks!

Code: Select all

for i in *.jpg; do

convert $i -crop 0x95%+0+0 +repage fix_$i 
done
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: cutting the height images by percent size

Post by fmw42 »

For geometry reference, see http://www.imagemagick.org/script/comma ... p#geometry.

-crop also works with -gravity. see http://www.imagemagick.org/script/comma ... hp#gravity

So you might also consider this to fill over the bottom right with a solid color:

Code: Select all

convert water.png \
\( -clone 0 -gravity southeast -crop 15%x20%+0+0 +repage \
-fill DarkOliveGreen -colorize 100% \) \
-gravity southeast -compose over -composite water_new.png
Image


or something like to composite a section from the bottom left over the bottom right:

Code: Select all

convert water.png \
\( -clone 0 -gravity southwest -crop 15%x20%+0+0 +repage \) \
-gravity southeast -compose over -composite water_new2.png
Image


or something like this to just fill in the star in the bottom right with texture from the bottom left:

Code: Select all

convert water.png \
\( -clone 0 -gravity southwest -crop 15%x20%+0+0 +repage \) \
\( -clone 0 -gravity southeast -crop 15%x20%+0+0 +repage \
-fuzz 30% -transparent yellow -transparent red \
-channel rgba -fill white -opaque none -fill black +opaque white \) \
\( -clone 1 -clone 2 -alpha off -compose copy_opacity -composite \) \
-delete 1,2 -gravity southeast -compose over -composite water_new3.png
Image

Inpainting would be similar to the last, but automatically find the best textures to match.
Post Reply