Loading GIF, removing transparency, saving JPG

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, xnview

Post Reply
ckress
Posts: 3
Joined: Tue Dec 11, 2007 10:11 pm
Location: Munich

Loading GIF, removing transparency, saving JPG

Post by ckress » Tue Dec 11, 2007 10:44 pm

Hi everyone,

I'd like to load a transparent GIF, remove its transpareny information and save it as a JPG with background color set to white.

Using GflAX 2.60 - GFL 2.70 (Light) and ASP/JScript, I've tried this:

Code: Select all

var o = Server.CreateObject("GflAx.GflAx");
o.EnableLZW = true;
o.LoadBitmap(Server.MapPath("C:\\Temp\\transp.gif");
Response.Write(Boolean(o.UseTransparency) + " -- " + o.BackColor + " --" + o.MaskColor + "<br>");
o.UseTransparency = false;
o.BackColor = 16777215;
Response.Write(Boolean(o.UseTransparency) + " -- " + o.BackColor + " --" + o.MaskColor + "<br>");
o.SaveFormat = 1; // AX_JPEG
o.SaveFormatName = "jpeg";
o.SaveJPEGProgressive = true;
o.SaveJPEGQuality = 100;
o.SaveBitmap(Server.MapPath("C:\\Temp\\new.jpg"));
Executing the code I get the following output:
false -- 16777215 -- 16777215
false -- 16777215 -- 16777215

It looks like GflAx doesn't recognise the transparent GIF. The JPG file is saved with a black background. I doesn't matter if I set UseTransparency and BackColor or if I comment it out.

How exactly do I convert GIF to JPG with removal of transpareny and setting a white background?

Every hint appreciated!

User avatar
XnTriq
Moderator & Librarian
Posts: 5434
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Post by XnTriq » Tue Dec 11, 2007 11:35 pm

xnview ([url=http://newsgroup.xnview.com/viewtopic.php?p=31842#31842]Convert PNG -> JPG, transaprency is black[/url]) wrote:
Gordon wrote:I am trying to convert PNGs with transparency to JPG, but the transparency is always black. I woudl like ti to be white. I have tried the -transpcolor option but I didn't do anything.

If it possible to set the transparency color converting to JPG?
Is this syntax correct?

... -out jpeg -transpcolor 255 255 255 -keepcspace -q 100 ...
You can't change the transparency color when saving in jpeg

ckress
Posts: 3
Joined: Tue Dec 11, 2007 10:11 pm
Location: Munich

Post by ckress » Wed Dec 12, 2007 1:32 pm

Hmm, is it possible then to open a GIF, set the background color to white and save it to GIF again, now without transparency?
From there I could convert it to JPG.

Is that possible? I don't know how to use UseTransparency, BackColor and MaskColor to achieve this.

Post Reply