RSS/Atom feed Twitter
Site is read-only, email is disabled

color to alpha is slow

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

4 of 4 messages available
Toggle history

Please log in to manage your subscriptions.

color to alpha is slow Dov Kruger 02 Jun 19:09
  color to alpha is slow Sven Neumann 03 Jun 00:23
  color to alpha is slow Simon Budig 03 Jun 00:28
  color to alpha is slow Tino Schwarze 03 Jun 09:49
Dov Kruger
2004-06-02 19:09:39 UTC (almost 20 years ago)

color to alpha is slow

Hello fellow gimpers,

Apologies if this is not the correct group, but the users email seems geared towards people who use menus, not code.

We are using gimp to batch process 3000 or so images per day generated from an oceanographic forecasting system. We need to make the background color of a 24bit png image transparent, and turn it into an 8 bit image because Internet Explorer can't handle alpha transparency evidently, more reason to use Mozilla. You might ask, why are we doing this? Answer: by pulling static background out of our maps, we achieve a massive bandwidth reduction on our forecast website, see http://onr.dl.stevens-tech.edu/webnyhos3 for the original, and http://onr.dl.stevens-tech.edu/wwwnyhos1/index3.html for the experimental transparent version.

We currently execute a script-fu that turns all white pixels transparent, then turns the 24-bit-per-pixel image into indexed mode with 255 colors, setting color 0 transparent. It seems to take approximately 1 second per image, and the images are not all that big (some are as little as 15k, though the bigger maps, like Long Island, are as big as 150k). We do 100 at a time in a script, because the command line literally gets too long after a while -- we could probably increase that number to 500 or even decrease it, but the dominant factor seems to be the time it takes to do these operations. The machine is a 2.6Ghz P4 with 2Gb of RAM, the raw CPU should be capable of a lot more than this, and I allocated 500M in the gimp configuration, could some garbage collection problem be an issue?

I suspect that color-to-alpha is the slow part. Is there anything we can do to speed this up, like convert the image to indexed, and just make color 0 transparent? Any help with code to programmatically make color entry n transparent would be great, we didn't find any reference to that.

Oh, and to everyone who works on gimp, you guys kick serious butt! What a tool!

thanks,
Dov

Sven Neumann
2004-06-03 00:23:18 UTC (almost 20 years ago)

color to alpha is slow

Hi,

Dov Kruger writes:

I suspect that color-to-alpha is the slow part. Is there anything we can do to speed this up, like convert the image to indexed, and just make color 0 transparent? Any help with code to programmatically make color entry n transparent would be great, we didn't find any reference to that.

Why don't you use gimp-by-color-select() followed by gimp-edit-clear()? Color-to-alpha seems like serious overkill for this job.

Sven

Simon Budig
2004-06-03 00:28:07 UTC (almost 20 years ago)

color to alpha is slow

Dov Kruger (dkruger@stevens.edu) wrote:

massive bandwidth reduction on our forecast website, see http://onr.dl.stevens-tech.edu/webnyhos3 for the original, and http://onr.dl.stevens-tech.edu/wwwnyhos1/index3.html for the experimental transparent version.

Sorry, these are two pages which have exactly the same image embedded.

We currently execute a script-fu that turns all white pixels transparent, then turns the 24-bit-per-pixel image into indexed mode with 255 colors, setting color 0 transparent. It seems to take

[...]

I suspect that color-to-alpha is the slow part. Is there anything we can do to speed this up, like convert the image to indexed, and just make color 0 transparent?

color-to-alpha indeed is computationally complex, because it not only makes the color picked transparent, but also pushes as much transparency as possible into all pixels, so that they appear the same as the original, when the extracted color gets composed behind it.

And then you destroy this by indexing the image, where gimp no longer supports partial transparency... :-)

Any help with code to programmatically make color entry n transparent would be great, we didn't find any reference to that.

Ok, I suspect that you'll save a lot of bandwidth by simply indexing the image to e.g. 64 colors or so, the fiddeling with transparency probably doesn't save you anything. And just indexing is probably way quicker by using a standalone commandline tool.

However, if you want to make e.g. all white pixels transparent you could index the image and then invoke gimp-by-color-select with appropriate parameters, and then select edit->clear (make sure to add an alpha channel if no one exists yet).

I hope this helps, Simon

Tino Schwarze
2004-06-03 09:49:59 UTC (almost 20 years ago)

color to alpha is slow

Hi Dov,

On Wed, Jun 02, 2004 at 01:09:39PM -0400, Dov Kruger wrote:

We do 100 at a time in a script, because the command line literally gets too long after a while -- we could probably increase that number to 500 or even decrease it,

As a side note: Try using xargs. It takes care for the "long command line" issue for you.

Bye, Tino.