Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read
Q&A

How to make background transparent and trim to content

+2
−0

Question

Is there a way in grafx2 to make the background transparent and trim to content?

This could be done during save.

My process now when making images for documents is:

  1. Make image in grafx2.
  2. Open image in gimp.
  3. Add alpha layer.
  4. Select background by color.
  5. Clear (it is now transparent).
  6. Crop to content.

It would be very convenient to have grafx2 achieve this.

Example Images

Before

Image alt text

NOTE: The black bar at the bottom is due to the entire page not properly filling white in grafx2.

After

Image alt text

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Can you show an example image? (4 comments)

1 answer

+2
−0

I don't know if or if not this is possible from within grafx2, but your manual workflow can be simplified dramatically by using image magick. The following command will do all your steps at once and reproducibly:

convert test.gif -transparent white -gravity south -chop x60 -trim output.png

resulting image after conversion with transparent background and cropped to the content

Explanation of the steps:

  • convert: calls the convert command from the image magick bundle (it may be called differently if you use windows)

  • test.gif: name of the input file

  • -transparent white replaces the white background with a transparent background

  • -gravity south -chop x60: cuts off 60 pixel from the bottom of the image to get rid of the black bar (the exact number might need find tuning, that was just my quick estimate)

  • -trim: will remove all superfluous space around your shape

  • output.png: name of the resulting file

(depending on how you make your documents, one might even incorporate this conversion into your document making workflow)

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

This is outstanding, thank you! Plus, if I figure out the cause of the black bar, the command becomes... (2 comments)

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!

Like what we're doing? Support us! Donate