Page 1 of 1

Conditional Resizing

Posted: 2013-07-14T03:53:20-07:00
by salahuddinonline
hi
I am facing problem in this, As I have multiple images to work on but do not want to review there canvases and Sizes
can any one help me out on this,
For Example

if Image is between 475x475 then set canvas as 500x500 with gravity center,
if image size is between 135x135 to 159x159 set gravity center and canvas as 160x160
but do nothing if image size is between 161X161 to 199x199,
and
if image size between 200x200 to 224x224 set gravity center and set canvas as 225x225
but do nothing if image is between 226x226 to 274x274
if image size is between 275x275 to 299x299 set gravity center and canvas as 300x300
but do nothing if image size is between 301X301 to 475x475,

kindly help me out on this,

Re: Conditional Resizing

Posted: 2013-07-14T06:21:39-07:00
by snibgo
You probably need to write a script. This would read the image size, and set the new size as needed (although I'm not quite sure what you are trying to do).

What is your platform: Windows, Unix, Mac or other?

Re: Conditional Resizing

Posted: 2013-07-14T07:21:14-07:00
by salahuddinonline
I am using linux ubuntu, I understand that I need to write an script but I have told that whatever I need to know how to set canvases in conditional resizing
if Image's size between 475x475 then set canvas as 500x500 with gravity center,
if image size is between 135x135 to 159x159 set gravity center and canvas as 160x160
but do nothing if image size is between 161X161 to 199x199,
and
if image size between 200x200 to 224x224 set gravity center and set canvas as 225x225
but do nothing if image is between 226x226 to 274x274
if image size is between 275x275 to 299x299 set gravity center and canvas as 300x300
but do nothing if image size is between 301X301 to 475x475,
I think I have described what I am looking for,
if anyone can write an script I would be thankful...

Re: Conditional Resizing

Posted: 2013-07-14T07:39:37-07:00
by snibgo
I don't use Unix so can't help you with the script.

Re: Conditional Resizing

Posted: 2013-07-14T07:54:24-07:00
by Bonzo
For the 500x500 canvas you would need to use extent:

Code: Select all

convert input_image -backround white -gravity center -extent 500x500 output_image
Just use the same imagemagick code for each of your sizes and just change the -extent values.

Re: Conditional Resizing

Posted: 2013-07-14T12:38:26-07:00
by GreenKoopa
Do you want the images resized (resampled), or are you wanting a border added? A colored border, or a transparent one? Are your initial images always square?

This could be done using only IM, but a script may be easier and more readable.

Re: Conditional Resizing

Posted: 2013-07-14T18:49:10-07:00
by salahuddinonline
Thanks for Asking Green,
Actually I dont wanna add border or color or any thing like them but I want to just resize canvas and said conditions

Re: Conditional Resizing

Posted: 2013-07-14T19:08:56-07:00
by GreenKoopa
I think Bonzo read your post as asking to place an image on a larger background canvas, which is understandable since you spoke of a canvas and gravity. If this is what you want, your canvas would need a color. If you do not want a background canvas, what do you mean by gravity?

Again, are your initial images always square?

You are asking for a complex conditional resize. Do you have a command working for one image you could give as an example of what you want?

Re: Conditional Resizing

Posted: 2013-07-14T19:18:32-07:00
by salahuddinonline
/home/$whoamI/Desktop/Images/Originals/
mogrify -path /home/$whoamI/Desktop/Images/converted/ -trim -gravity center -resize 300x300 -extent 300x300 *.jpg

I do not have images in square, but in different Dimensions, For Example 480x320 or 2375x2500
I want to resize images As per conditions given by me,

Re: Conditional Resizing

Posted: 2013-07-14T19:51:59-07:00
by GreenKoopa
Okay, that is a start. To use your example, you begin with a 2375x2500 image. I do not understand which conditional case it falls under? I do not understand what exactly you want done?

Re: Conditional Resizing

Posted: 2013-07-14T20:20:53-07:00
by snibgo
Confusingly, two threads have been started on this topic, under "Users" and "Developers".

Can a moderator merge them?

Re: Conditional Resizing

Posted: 2013-07-14T23:00:01-07:00
by GreenKoopa
This entire thread can be deleted. All of the useful information is in this thread in the Developers forum.

how to remove its shadow and get trimmed and sized

Posted: 2013-07-16T02:36:45-07:00
by salahuddinonline
hi there
can any one tell me what should be done if I want to use this image and remove its shadow background is white then trim it edge to edge then resize it with size either X or Y (whichever is larger )
I am using linux ubunto
I want to apply this to whole directory
there is nothing except images in this directory

Re: Conditional Resizing

Posted: 2013-07-16T08:46:47-07:00
by snibgo
This isn't about Conditional Resizing, so start a new thread. And supply an example image.