Page 1 of 1
Problem with -negate on specific png file
Posted: 2018-06-07T10:21:29-07:00
by fenryhord
Hey I am a new user and just tried the -negate function on this file (
https://imgur.com/a/LNuo2F7).
If i use this line: "magick convert base.png -negate negate_base.png" is doesnt work. It just gives me a black image.
with this: "magick convert base.png -negate negate_base.jpg" it works.
It also works when i rename the png file to "*.jpg"???? (no clue why) and alter the code to fit the new file-ending.
Maybe somebody can help here?
regards
Re: Problem with -negate on specific png file
Posted: 2018-06-07T10:28:37-07:00
by fenryhord
Ok did some testing with the -channel attribute.
When i specify -channel RGB it works with this: "magick convert base.png -channel RGB -negate negate_base.png"
Isn't RGB the default one?
regards
Re: Problem with -negate on specific png file
Posted: 2018-06-07T11:17:44-07:00
by fmw42
Your image has transparency. JPG does not support transparency. Using -channel rgb tells IM to only negate channels r, g, b (each separately) and not alpha.
So you should flatten the image first and then negate if you want to convert to JPG. Also note that with IM 7, you should use only magick and not magick convert.
Code: Select all
magick img.png -flatten -negate img7.jpg
Re: Problem with -negate on specific png file
Posted: 2018-06-07T11:29:14-07:00
by fenryhord
OK thanks. My initial idea was not to convert it (png -> png) which didn't worked.
I was confused when it worked when i converted (png -> jpg).
One different question for that type of image should i use jpeg or png?
regards
Re: Problem with -negate on specific png file
Posted: 2018-06-07T11:38:26-07:00
by fmw42
Use of JPG or PNG depends upon what you want to achieve. If you need to keep alpha, then you should use PNG. If you want the smaller file size, then use JPG. But do not use JPG for any intermediate format, only your final image.
Re: Problem with -negate on specific png file
Posted: 2018-06-07T11:44:11-07:00
by fenryhord
Ok thanks.
That was all.
Do i need to close this post or something?
regards.
Re: Problem with -negate on specific png file
Posted: 2018-06-07T12:29:00-07:00
by fmw42
No you do not. But if you want to, you can go the the title of your first post in this topic and add [RESOLVED] or something like that at the beginning.