It is currently Fri May 03, 2024 6:34 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: automatically turn white background transparent
PostPosted: Thu Nov 18, 2010 9:15 am  (#1) 
Offline
GimpChat Member

Joined: Nov 18, 2010
Posts: 8
Hi im new here!

i have many black and white silhouette .eps files that i want to save as .png with transparent backgrounds. so im using david's batch conversion plugin, but it opens the .eps files with a white background there, therefore saving the png with the same.

i think i need a way for gimp to open up .eps files and automatically recognise the white background and turn it transparent, therefore i think the .pngs will save like that.

i know i can either 'select by colour' or use 'colour to alpha' but that requires opening up each file...and i have hundreds!!

INTERESTINGLY a colleagues photoshop already does this! it recognises the .eps file's white background and turns it transparent! this is what i want gimp to do

thanks!


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Thu Nov 18, 2010 11:04 am  (#2) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
One way would be to open an eps file in gimp, then Colors > Color to Alpha. Make sure the color selected in there is white.

It might be useful if you were to zip one of your eps images and attach it in here so we could experiment with it.

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Thu Nov 18, 2010 11:19 am  (#3) 
Offline
GimpChat Member

Joined: Nov 18, 2010
Posts: 8
Hi Ore

thanks but i mentioned i tried 'colour to alpha' technique but it would requires opening up each file, doing that technique and saving, before i then save as png!

there might be a way so that upon opening the file the white background changes to transparent automatically

i cant see the option here to attach but you should be able to get it from here, i uploaded it

http://www.sendspace.com/file/q0qi4p


Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Thu Nov 18, 2010 11:59 am  (#4) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
Are you unchecking the "save background" option on the batch processor, for png output?

UPDATE: Actually, it doesn't make any difference, I just tested a transparent .eps file, and it added a white background. When I downloaded your file, it opened with a white background.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Thu Nov 18, 2010 5:10 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Davids batch plug-in is all i can think of to use.
Try posting a question about it on the gimp repository forums.
Someone will probably make you a script for it...lol
Or ask for a batch script to handle eps files here in scripts and plug-ins area of the forum.
We have many great scripters, and coders that visit here.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Fri Nov 19, 2010 9:36 am  (#6) 
Offline
GimpChat Member

Joined: Nov 18, 2010
Posts: 8
thanks mahvin, yes i was doing that

thanks Rod, yes davids batch processor is great! i think a specific scirpt is needed.

what im finding is that upon opening the .eps files in gimp, the image is flattened so that the original background is removed. if one opens up the file in its originator Adobe Illustrator the background is recognised exactly the that same as it is in Photoshop!


Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Fri Nov 19, 2010 9:40 am  (#7) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
Have you tried opening the transparent eps file in Inkscape? Just curious.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Fri Nov 19, 2010 12:27 pm  (#8) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
I've written a script that might just do the job. I've assumed the settings for the png save. If you find you want different settings than let me know, or try editing the script yourself :)

I've made it so it can either be run interactively - it will appear under a contributed menu, or it can be run in batch mode from the command line.


Attachments:
eps_to_png_batch_job.scm [2.73 KiB]
Downloaded 931 times

_________________
Kevin
Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Mon Nov 22, 2010 9:03 am  (#9) 
Offline
GimpChat Member

Joined: Nov 18, 2010
Posts: 8
thanks mahvin, yes i tried inkscape and the .eps files wont open (failed to load)

thanks paynekj, that was blinking incredible! your script does the whole process very well indeed, it even negates the need to use david's batch processor! i am suitably impressed mate and now long to know how to write scripts for gimp! also, id like to know how to see the png settings you set?

cheers :-D


UPDATE

it is strange how when i used david's batch processor, many of the files ended up as 2.5mb each! whereas paynekj's method achieved much less (this is a good thing). also paynekj's method not only removes the white background but it also crops the file to the extent of the resulting image (also a good thing! paynekj did you intend this to happen?!?); i guess this goes towards reducing the file size.


Last edited by siwilks200 on Mon Nov 22, 2010 9:33 am, edited 1 time in total.

Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Mon Nov 22, 2010 9:33 am  (#10) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
If you have a look at this line in the script:

(file-png-save RUN-NONINTERACTIVE image drawable png_filename png_filename FALSE 9 FALSE FALSE FALSE FALSE FALSE)


And compare with the entry for file-png-save in the procedure browser (Help>Procedure Browser) the parameters are:

run-mode       (do you want to prompt the user or not)
image           the internal id of the image
drawable        in this case it's the internal id of the only layer
filename        is the name of the file to save the image in (png_filename)
raw-filename    is the raw name of the file to save the image in (png_filename)
interlace       use Adam7 interlacing? (= FALSE)
compression     compression factor (=9)
bkgd            Save background colour (=FALSE)
gama            Save gamma (=FALSE)
offs            Save layer offset (=FALSE)
phys            Save resolution (=FALSE)
time            Save creation time (=FALSE)


Update:
You wrote your update while I was writing this reply. I didn't deliberately do anything to crop the images, so I'm guessing that they are being cropped when they are loaded into Gimp. As for the size, that will probably be because I set the compression level to it's maximum (=9).

_________________
Kevin


Top
 Post subject: Re: automatically turn white background transparent
PostPosted: Mon Nov 22, 2010 3:47 pm  (#11) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
Hi-

little late to this. I wrote a script to do this a while back: http://www.silent9.com/incoming/scripts/transbg.scm

It overcomes the disadvantage of doing it paynekj's way which will turn grey colours partially transparent. Unfortunately my script isn't set up to run in batch.

I haven't tried it, but you should be able to combine the two by changing his line:
(plug-in-colortoalpha RUN-NONINTERACTIVE image drawable '(255 255 255)) ; convert white to alpha

to:
(script-fu-trans-bg image drawable 25 5 TRUE) ; calls RobA's script

with my script also installed. You might want to experiment with the two parameters as well by calling the script manually a few times.

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Remove white background but keep white inner

6

No new posts Attachment(s) Transparent background in screenshot

8

No new posts Attachment(s) Use of Fuzzy Select tool to remove white background from black text

2

No new posts Attachment(s) GEGL Edge Extract - Edge Neon's algorithm in transparent background

9

No new posts Attachment(s) automatically crop?

2


cron

* Login  



Powered by phpBB3 © phpBB Group