What is wrong with my Glitter Text Code.

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
sabater_wb

What is wrong with my Glitter Text Code.

Post by sabater_wb »

I'm trying to create glitter texts with imagemagick.

I wrote the code below, according to this page: http://myspace-webgraphics-software.net ... itter.html

Code: Select all

<?

exec("convert -background transparent -font 'angelina.ttf' -pointsize 72 label:Glitter -stroke black -strokewidth 2 -clone 0 -tile 'tile.gif[0]' -stroke black -strokewidth 2 -gravity center -annotate +0+0 Glitter -clone 0 -tile 'tile.gif[1]' -stroke black -strokewidth 2 -gravity center -annotate +0+0 Glitter -clone 0 -tile 'tile.gif[2]' -stroke black -strokewidth 2 -gravity center -annotate +0+0 Glitter -delete 0 -set delay 15 -loop 0 -trim +repage -layers Optimize result.gif");

?>
But the problem is that the result is a animated gif with all the 3 frames black.
If I change "background transparent" to "background white", so the words appear, but the generated gif is always in grayscale.

I don't know, what is wrong with my code.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: What is wrong with my Glitter Text Code.

Post by el_supremo »

You've left out the parentheses in the command - they are essential to making it work properly.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
sabater_wb

Re: What is wrong with my Glitter Text Code.

Post by sabater_wb »

Where I need to put the parentheses, please?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: What is wrong with my Glitter Text Code.

Post by el_supremo »

The command you copied from http://myspace-webgraphics-software.net ... itter.html has three open parentheses \( and three close parentheses \) which you didn't include in your command. They must be there.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: What is wrong with my Glitter Text Code.

Post by anthony »

It looks as if the examples are copied from and posibly expanded (with out the results displayed) from IM examples
http://www.imagemagick.org/Usage/anim_mods/#glitter

I'll have to go through it and see if I can roll any additions back into IM Examples.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: What is wrong with my Glitter Text Code.

Post by anthony »

Addendum...


My glitter examples does not do each frame of the glitter time, one frame at a time, but uses the -layers composite and -distort tiling to handling the glitter tile AS IS.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sabater_wb

Re: What is wrong with my Glitter Text Code.

Post by sabater_wb »

thank you el_supremo. I got it.

But the result was terrible, with transparent background.

See it.
Image

what can be wrong?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: What is wrong with my Glitter Text Code.

Post by el_supremo »

Remove "-layers optimize" from your command. I don't know why, but this was causing a black background when I tried it.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: What is wrong with my Glitter Text Code.

Post by anthony »

You have just hit a bug I have been reporting for some time.

It has only happened to me in ONE example.

The bug is with transparent background and is caused not by the -layers optimize, but by something in the GIF saving.

For example if you save to miff format instead of GIF it animates correctly, though not very helpfully.


I think the bug may be related to a color selection fault in the Dither process of the Color Reduction needed for GIF. The same bug which is current causing GIF images to only use about 1/4 of the colors the color quantization generates, or even prventing exact output to GIF of images with less than 256 colors.

This problem is well known, has been reported many times, but Chrisy does not currently have time to track down a complex bug like this (work commitments). One attempt was made but it was rolled back as it caused other problems.

I myself do not have time or the knowledge of this aspect of the IM code to fix the problem, sorry. However others are welcome to try. IM is open source!

I will however take a look at the command and see if I can reproduce the problem.

NOTE: -layers optimize is actually a mutliple optimization command including frame optimization, single global color map, and transparent compression optimization. You may be able to avoid the bug by using these optimizations separately, rather than using the all in one method.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: What is wrong with my Glitter Text Code.

Post by anthony »

In my experiments -layers Optimize does fail - throug hit only produces a solid black background, rather than the variable (blocky) one you show.

Without any optimization I get a image (different font) 32942 bytes
Adding -layers OptimizeFrame I get 32916 bytes
whcih is not a big saving but then that was expected as the whole image is
animated
Adding -layers OptimizeTransparency as well and I get 32193 bytes.

Now adding -quantize transparent +map to use a common global color map and result FAILS. Again it looks like specific instances of dithering.

So replace -layers Optimize with -layers OptimizeFrame -layers OptimizeTransparency for the time being until the problem can be fixed.


Hmmm output the result to miff:- | animate shows
that a semi-transparent color is being used instead of fully transparent. That should not be happening as -quantize transparent is supposed to ignore transparency in determining color in the output! This is a Quantization failure!!!!! However I also get variable transparency from frame to frame, which means the Dither color selection is also failing!!!!!

Arrrggghhhhh.......
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: What is wrong with my Glitter Text Code.

Post by anthony »

Alternative glitter text example.

This one does NOT care about the number of images in the glitter tile :)
but requires a 'viewport' size that is larger than the text image size. :(

Code: Select all

convert  -background none  -strokewidth 2 \
  -font Candice  -pointsize 72  label:'Glitter Text' \
  \
  null: \
  \( tile.gif -set option:distort:viewport 500x100 \
    -virtual-pixel tile -distort SRT 0 \) \
  -compose In -layers Composite \
  \
  null: \
  -fill none -stroke black label:'Glitter Text' \
  -compose Over -layers Composite \
  \
  -loop 0 -trim +repage \
  -layers OptimizeFrame \
  -layers OptimizeTransparency \
  result.gif
NOTE if you know what type of background the text is going to be displayed on you can generate a better edge to the animation.

For example on a very light background (light shading edging)

Code: Select all

convert  -background none  -strokewidth 5 \
  -font Candice  -pointsize 72  label:'Glitter Text' \
  \
  null: \
  \( tile.gif -set option:distort:viewport 500x100 \
    -virtual-pixel tile -distort SRT 0 \) \
  -compose In -layers Composite \
  \
  null: \
  \( -background white -fill black -stroke black \
     label:'Glitter Text' \
     -fuzz 20% -transparent white \) \
  -compose DstOver -layers Composite \
  \
  -loop 0 -trim +repage \
  -layers OptimizeFrame \
  -layers OptimizeTransparency \
  gif:- | animate &
For a Gray background just replace the two 'white' arguments with 'gray'.
and so on for other backgrounds. (lightblue, cream, etc).


I hope from this, that you can see the beauty of the multi-image -layers Composite operator. Now if we can get a composite tiling setting, we can make this even simpler!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sabater_wb

Re: What is wrong with my Glitter Text Code.

Post by sabater_wb »

Thank you anthony. It worked.
sriducati
Posts: 28
Joined: 2011-11-28T08:11:59-07:00
Authentication code: 8675308

Re: What is wrong with my Glitter Text Code.

Post by sriducati »

i have used all the code specified here but none worked .....
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: What is wrong with my Glitter Text Code.

Post by anthony »

Start a new thread with examples. Also your IM version.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply