Page 1 of 1

help 2 separate commands on the one line

Posted: 2014-05-30T08:00:49-07:00
by seosamh
Hi All, new to the foum and new to imagemagick!

I've got imagemagick running on a website and since the person that dealt with this left long ago I get the pleasure of figuring it all out as we(I) want to change things, I'm actually enjoying it so far, pretty powerful tool. (I'm coming from photoshop!).

Problem I'm having is:

I've got large and small images and I want to convert them both to a certain size based on orientation(I've got that ok), say 1500x1500, the larger files I want to reduce, the smaller files make larger but I want to play around with different types of interpolation for each command. (I'm using quality though just to confirm that it's working before I delve into that)

My command so far is: (I'm using window command line for test before I send onto the IT people to implement, I know there are syntax differences)

convert *.jpg -resize 1500x1500^> -quality 100 -resize 1499x1499^< -quality 1 test.jpg

i've just got the quality set to 1 and 100 so that I can test it's working at the moment.

To explain further I've have variable image size, but I want images above 1500px(wide or tall) to reduce in size, but images below 1500px(wide or tall) to increase insize, but I only want to apply certain filters to the ones i'm increasing in size(Although I might want to apply a different set to the reduced version, but I've still to test)

I could run both commands separately, but I want to run them at the same time, but to generate different outputs.

Is there anyway to group these commands so that they run independently? ie. the first resize and quality v the second resize and quality?

Anyway I hope I've explained that well, any help would be appreciated?

Thanks

joe

Re: help 2 separate commands on the one line

Posted: 2014-05-30T08:07:37-07:00
by seosamh
windows version 6.8.9-1

Re: help 2 separate commands on the one line

Posted: 2014-05-30T08:49:49-07:00
by snibgo
I'm not quite sure what you are asking.

"-resize" can use a "-filter" option. Is this what you mean? If you don't specify "-filter", it will use a default, which is different for increasing or decreasing sizes (aka supersampling vs subsampling).

"-quality" is an option for the final writing of the jpeg. It has no other effect. Therefore your first "-quality" is ignored.

You seem to want each input file to make only one output. Is that correct?

The basic command ...

Code: Select all

convert in.png -filter {something} -resize 1500x1500^> -filter {something_else} -resize 1499x1499^< out.png
... might do what you want. "-filter {something}" will be ignored for small images. "-filter {something_else}" will be ignored for large images.

But some tweaking that NicolasRobidoux discusses, such as "-sigmoidal-contrast", actually change the image, and you probably don't want to do them twice.

To be honest, if your inputs and outputs are JPG, I doubt that "-filter" is of much use to you.

Re: help 2 separate commands on the one line

Posted: 2014-05-30T09:17:06-07:00
by seosamh
Yes, I thought I may be explaining things wrong, I'm obviously using the terminology filter wrong, not what I want to do. Ignore that I said filter, that obvious means something else.

I want to group things together.

ie

If an image is less than say 1500 pixel, enlarge to 1500px, if and image is greater than 1500px, reduce to 1500px.

That's fine I can get that working, but i'm struggling to figure out how I can increase the complexity of this.

in the sense that, if an image is being increased in size I want to apply a quality setting(if not increased leave it alone), if and image is being reduced insize I want to apply a quality setting(If not reduced, leave it alone)

currently at the moment, you're correct it's ignoring the first quality setting and applying that to all images.

I'm only using quality to test it as I'll be different commands I want to use, for example I want to play around with different interpolation methods and stuff and apply them as above like the quality(not exactly sure yet, like I say i'm just at the stage of figuring out the correct language to use) My thinking is if I can get the quality setting to do what I want, I'll be easy enough to expand that logic to other things, once I understand that.

Like I said as well, I'm coming from photoshop, so I know what things can do and have a sense of how i'd like things to work, it's how to combine commands and only apply to certain bits that i'm struggling with. once I understand that I'll be flying I reckon.

Sorry if I'm being unclear, I think possibly my inexperience isn't helping my explanatory skills.

Re: help 2 separate commands on the one line

Posted: 2014-05-30T09:49:17-07:00
by snibgo
I don't think you can decide on a quality setting within the command.

You could have the single command create two outputs, with different quality settings, eg (Windows BAT syntax):

Code: Select all

convert in.jpg ^
  ( +clone -resize 1500x1500^> -quality 100 -write out1.jpg +delete ) ^
  -resize 1499x1499^< -quality 1 out2.jpg
You can play with other settings before each output, if you want. But this command would always give you two outputs. You might then decide which one to keep.

It may be easier to find the size of the image first, then execute one or other "convert", depending on the size.

Code: Select all

for /F "usebackq" %%L in (`%IM%convert -ping %SRC% -format "IsBig=%%[fx:w>1500||h>1500?1:0]" info:`) do set %%L

echo IsBig=%IsBig%

if %IsBig%==0 (
  convert %SRC% ...
) else (
  convert %SRC% ...
)

Re: help 2 separate commands on the one line

Posted: 2014-05-30T10:12:17-07:00
by seosamh
Ta, I'll have a wee play around with trying to figure that out when i'm back in on Monday.

Seems like I'll need to figure ouT BAT syntax and how to run that too.

Thanks, some food for thought here. I'll no doubt be back!