Problems in the MNG lab (alpha & keys)

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
se7
Posts: 5
Joined: 2010-01-25T18:22:52-07:00
Authentication code: 8675309

Problems in the MNG lab (alpha & keys)

Post by se7 »

I'm facing an insane problem with getting the correct conditions in an application. Here are the conditions my mng needs to meet. I'm not entirely sure if ImageMagick is capable of this. As such I will be providing successful files to compare
  • PNG files utilized in an MNG while preserving the alpha blending the PNG originally had.
  • Customized comment keys for some frames, but choosing to leave some frames blank (no repeat of keys).
MNG for sure supports what I'm trying to do. I succeeded in using software to force this Transparency. I haven't succeeded with ImageMagick yet.

ImageMagick makes strange comment keys that don't seem to be the same as what is needed. Yet the software I made the alpha in for the MNG can't do keys properly because it requires the "Comment:" prefix which breaks the image for the application this is intended for.

Successful Alpha, bad MNG keys:
http://sonic-club.com/users/se7/magick/ ... eAlpha.mng

No alpha, but good MNG keys:
http://sonic-club.com/users/se7/magick/ ... ntKeys.mng

Both of those images were made in totally different software, but not ImageMagick.

I can show some of my ImageMagick code, but it is mostly failure. These are some of my experiments so far anyway. I'm using exec by the way, if you're wondering the strange string format.

convert -delay 100 -dispose 2 -set _move_2 ' ' alpha01.png -delay 200 alpha02.png alpha03.png -set _move_8 ' ' alpha04.png alpha05.png alpha06.png alpha07.png alpha08.png +set create-date +set modify-date result.mng

Another issue I have with -set is that it sets for all frames following. I only want it to do the single frame and leave any blank that aren't labeled.

I don't mean to drag out the explanation and make it so complicated. I put off asking for a while so I am a bit more disorganized than I would be. I'm basically asking for how to do that kind of alpha in Image1, with the proper keys of Image2.

Any leads that would put me onto the right track would be much appreciated. I'll follow-up if I have any more information that will help. Thank you.
se7
Posts: 5
Joined: 2010-01-25T18:22:52-07:00
Authentication code: 8675309

Re: Problems in the MNG lab (alpha & keys)

Post by se7 »

It's confirmed, I have hit a definite dead end with the -set command. So I would like to focus on only that at first unless anyone wants to take on the alpha issue also.

The -set command takes a key and a value according to the manual. However, I want a key's value boolean (0, false, null, etc.), but those attempts fail and leaving it blank simply ignores the key completely.

This is how I attempted:
-set _move_4 ''

I only want a key name, no value, so I used two apostrophes to try to tell it "here's the value, I want it blank". It doesn't like that and ignores the -set command completely. If I do nothing and take away the ' then it uses the next part of the command as the key.

Here is the place in the manual I keep referring to: http://www.imagemagick.org/script/comma ... ns.php#set

My null attempt works good for something. I can disable create-date and modify-date by doing this:
-set create-date ''
-set modify-date ''

I wouldn't mind them, but they repeat that information on each frame, ultimately leading to a slightly bigger filesize. This is another problem i'm having.


So here are my questions:
  • Any way to assign a -set to only one frame within the MNG animation without it repeating over and over?
  • How/Can a null value be acknowledged by ImageMagick so that the -set key's value is completely blank?

Off Topic:
When going over the manual a few times I noticed a typo. Does it matter? If so, how would I report that? Only if it's helpful.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Problems in the MNG lab (alpha & keys)

Post by glennrp »

The PNG spec allows tEXt chunks with no text beyond the keyword,
but there seems to be no way to use "-set key <nothing>" to accomplish that.
This works, though:

Code: Select all

echo -n "tEXt\0_MOVE_2" > move_2.txt
echo -n "tEXt\0_MOVE_8" > move_8.txt

convert -delay 100 -dispose 2 \
           -set profile PNG-chunk-b01:move_2.txt \
           [etc.]

This writes _MOVE_8 twice, though, so needs a little more thought../glennrp
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Problems in the MNG lab (alpha & keys)

Post by glennrp »

Adding some parentheses helps:

Code: Select all

convert -delay 100 -dispose 2 \
           \( -set profile PNG-chunk-b01:move_2.txt xc:white \) \
           \( +set PNG-chunk-b01: \
           -delay 200 xc:black  xc:red \) \
           \( -set profile PNG-chunk-b02:move_8.txt xc:pink \) \
           +set PNG-chunk-b02: \
           +set create-date +set modify-date result.mng
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problems in the MNG lab (alpha & keys)

Post by anthony »

se7 wrote:convert -delay 100 -dispose 2 -set _move_2 ' ' alpha01.png -delay 200 alpha02.png alpha03.png -set _move_8 ' ' alpha04.png alpha05.png alpha06.png alpha07.png alpha08.png +set create-date +set modify-date result.mng

Another issue I have with -set is that it sets for all frames following. I only want it to do the single frame and leave any blank that aren't labeled.
Actually you are wrong in your assumption.

-set sets the given setting to ALL the images in the current image sequence. It does NOT effect any new images that are loaded after it.

This also explains the difference between -delay which is a setting effectly image later read in,
and -set delay which modifies all the images that has already bee read in.

All this is explained in IM Examples, Basics, Image Meta-data: Attributes, Properties and Artifacts
http://www.imagemagick.org/Usage/basics/#settings

If you want to apply a setting to a specific image make a clone in a new image sequence generated with \( ... \) and then use that modified image to replace the original.

For example, with a set of 10 images, I first sets the "comment" of all images to a string containing a calculated number, but then modifies the 3rd last image (index=8) to something else...

Code: Select all

convert xc:  -duplicate 9 \
             -set comment 'T minus %[fx:n-t]' \
             \( -clone 7 -set comment 'We have ignition!' \) -swap 7 +delete \
             -format "image #%p : %c" info:
image #0 : T minus 10
image #1 : T minus 9
image #2 : T minus 8
image #3 : T minus 7
image #4 : T minus 6
image #5 : T minus 5
image #6 : T minus 4
image #7 : We have ignition!
image #8 : T minus 2
image #9 : T minus 1
this is a good example, which I will add to the "Basics" page.


I don't mean to drag out the explanation and make it so complicated. I put off asking for a while so I am a bit more disorganized than I would be. I'm basically asking for how to do that kind of alpha in Image1, with the proper keys of Image2.

Any leads that would put me onto the right track would be much appreciated. I'll follow-up if I have any more information that will help. Thank you.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply