filter results completely different in IM 6.9 and IM 7

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
takosuke
Posts: 5
Joined: 2016-10-19T06:05:41-07:00
Authentication code: 1151

filter results completely different in IM 6.9 and IM 7

Post by takosuke »

Hi!I'm trying to make use of the instagram filters that have been around forever (here's a link to a python implementation, but they are all the same underlying commands) for a little windows app.
Unfortunately, the commands that use the colortone function work fine in IM up until 6.9, then go crazy in current versions

here's the conflicting commands:
magick.exe convert infile.jpg ( -clone 0 -fill #222b6d -colorize 100% ) ( -clone 0 -colorspace gray -negate ) -compose blend -define compose:args=50,50 -composite nash01.jpg
magick.exe convert nash01.jpg ( -clone 0 -fill #f7daae -colorize 100% ) ( -clone 0 -colorspace gray ) -compose blend -define compose:args=120,-20 -composite nash02.jpg

(I've omitted the final color correction and framing of the image because that doesn't act funny)
I'm using Imagemagick 7.0.3-4 on windows (tried q8 and q16 as well as both 32 and 64 bits to see if it made a difference...). They work fine on 6.9.6-2

I looked over the changes to version 7 and the only thing I gleamed out of it was that the -negate option now needs to have -channel RGB specified beforehand to not affect the alpha as well, but doing ( -clone 0 -colorspace gray -channel RGB -negate ) doesn't change anything

I appreciate any hints!I'd love to be able to make a script that was compatible with both versions, but for now I'm happy to get it working on IM 7...
Here's the images I'm getting:

original image:
Image

first colortone in IM 6.9:
Image

second colortone in IM 6.9
Image

first colortone in IM 7:
Image

second colortone in IM 7:
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: filter results completely different in IM 6.9 and IM 7

Post by snibgo »

With v7.0.2-5, your commands seem to work fine if you use "magick" instead of "magick convert".
snibgo's IM pages: im.snibgo.com
takosuke
Posts: 5
Joined: 2016-10-19T06:05:41-07:00
Authentication code: 1151

Re: filter results completely different in IM 6.9 and IM 7

Post by takosuke »

uh???
Yes they do but...why is that?what's the difference between using magick and magick convert?And more importantly, is this behaviour going to keep changing in successive versions?I'm very confused about all this executable name changing that seems to be happening.

According to the porting to IM 7 guide:
To reduce the footprint of the command-line utilities, these utilities are symbolic links to the magick utility. You can also invoke them from the magick utility, for example, use magick convert logo: logo.png to invoke the convert utility.

so magick and magick convert should be equivalent, right?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: filter results completely different in IM 6.9 and IM 7

Post by snibgo »

takosuke wrote:so magick and magick convert should be equivalent, right?
Well, no, not exactly.

"magick" alone is the new V7 usual program for ImageMagick.

"magick convert" is (I think) the command to use if you need the rest of the command to be interpreted in the v6 way. For example, v6 and v7 have different expectations for what script files may contain when called with "@".

I suggest: if you use v7, you should generally use "magick". Use "magick convert" only when you know you need it.
snibgo's IM pages: im.snibgo.com
takosuke
Posts: 5
Joined: 2016-10-19T06:05:41-07:00
Authentication code: 1151

Re: filter results completely different in IM 6.9 and IM 7

Post by takosuke »

I see. Thanks. Is that explained in depth somewhere?I don't see that being mentioned in the "porting to Imagemagick version 7" document, and I'm having new issues with my scripts when i use magick instead of magick convert. I also don't get why the commands i explained above work fine in v6 but give funky results when using magick convert in v7...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: filter results completely different in IM 6.9 and IM 7

Post by snibgo »

My comments and suggestions are my own personal comments and suggestions, not official in any way.

As far as I know, the V7 porting guide is the only official word.

Incidentally, I don't know why your commands gave bad results with "magick convert". See my bug report viewtopic.php?f=3&t=29675&p=139017#p139017 , and the update I have just made. I suspect you are hitting this bug.
snibgo's IM pages: im.snibgo.com
takosuke
Posts: 5
Joined: 2016-10-19T06:05:41-07:00
Authentication code: 1151

Re: filter results completely different in IM 6.9 and IM 7

Post by takosuke »

ha, ok, thanks for all the help!I'm in a crossroad between a bug and command syntax change...
I figured out how to make mostly everything work except for 2 things

the most troubling one is that i don't know how to translate this command
magick convert ( infile.jpg -auto-gamma -modulate 120,50,100 ) ( -size 557x800 -fill rgba(255,153,0,0.5) -draw "rectangle 0,0 557,800" ) -compose multiply kelvin.jpg

if i chain them with -clones like this
magick infile.jpg ( -clone 0 -auto-gamma -modulate 120,50,100 ) ( -clone 0 -size 557x800 -fill rgba(255,153,0,0.5) -draw "rectangle 0,0 557,800" ) -compose multiply kelvin.jpg

i get a bunch of intermediate files so called kelvin1.jpg kelvin2.jpg etc and the final one has the desired result, but the intermediate files and the name change break my scripts...i guess im just not understanding how composing works but I can't get my head around it


The other thing is the -contrast option which has now been replaced by the -level option. It still works but I'd rather not have the error, so I tried to emulate the exact -level settings that the -contrast option produces but without success (its also not on the porting to v7 document). I figured something that's close enough but i'm still puzzled by it!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: filter results completely different in IM 6.9 and IM 7

Post by snibgo »

magick convert ( infile.jpg -auto-gamma -modulate 120,50,100 ) ( -size 557x800 -fill rgba(255,153,0,0.5) -draw "rectangle 0,0 557,800" ) -compose multiply kelvin.jpg
The stuff in the second parenthesis is bad.
( -size 557x800 -fill rgba(255,153,0,0.5) -draw "rectangle 0,0 557,800" )
"-size" does nothing because you are not creating an image. "-fill" is a setting for "-draw", but what are you drawing on?

Logically, the command makes no sense. Unfortunately, IM v6 would do something with illogical commands, but it was difficult for us humans to predict what that was.

You set "-compose Multiply", but nothing uses that setting. I guess you forgot to add the "-composite" operator.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: filter results completely different in IM 6.9 and IM 7

Post by fmw42 »

Why not use -brightness-contrast?
takosuke
Posts: 5
Joined: 2016-10-19T06:05:41-07:00
Authentication code: 1151

Re: filter results completely different in IM 6.9 and IM 7

Post by takosuke »

thanks, Im still getting around how the IM pipeline works and was using those commands blindly copied from somewhere else. The stuff that you point out as illogical made no sense to me either but it worked when i copied them into IM 6 so I assumed it was me failing to understand something
Also thanks for pointing out -brightness-contrast. I will try this stuff out and make a fork of the python instagram filters repo with the updated commands for everyone's benefit...
Post Reply