It is currently Tue Jul 02, 2024 2:54 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Clipping and Alpha using two generated source images
PostPosted: Sat May 30, 2020 2:34 pm  (#1) 
Offline
New Member

Joined: May 30, 2020
Posts: 3
GIMP Version: 2.8.14
Operating System: Windows
GIMP Experience: Basic Level



So I have a open-source tool that extracts images from pdf files that I own for my own personal, non-commercial purposes. Two files of interest are generated (see attached), image and mask.

I'd like to use the mask file to delimit the image file, just the image area under the white mask will make it through. After that process, the area corresponding to black on (another duplicate copy of ?) the mask will be converted to alpha and saved.

The end result will be a nicely cleaned up image with an alpha channel background, stored as a png... all without manually brushing or erasing anything with a mouse. Just menu/button selections.


Attachments:
File comment: Mask file for the previous image-0007.png
image-0008.png
image-0008.png [ 29.13 KiB | Viewed 3079 times ]
File comment: Image file to be cleaned up by mask file, and alpha added.. eventually automated.
image-0007.png
image-0007.png [ 461.63 KiB | Viewed 3079 times ]
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: Clipping and Alpha using two generated source images
PostPosted: Sat May 30, 2020 3:09 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Apr 15, 2017
Posts: 1826
Just add a layer mask to your image and copy and paste your mask image into the layer mask, then save as a png.

Attachment:
mask.png
mask.png [ 505.9 KiB | Viewed 3067 times ]


Top
 Post subject: Re: Clipping and Alpha using two generated source images
PostPosted: Sat May 30, 2020 5:48 pm  (#3) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
racer-x wrote:
Just add a layer mask to your image and copy and paste your mask image into the layer mask, then save as a png.

Attachment:
mask.png


Mystrzy: GIMP has changed the way we save files, so actually use the Export As option is the same as saving the file as... it takes a little getting used to, just so you know.

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


Top
 Post subject: Re: Clipping and Alpha using two generated source images
PostPosted: Sat May 30, 2020 6:55 pm  (#4) 
Offline
New Member

Joined: May 30, 2020
Posts: 3
Your image looks good. However, there is a lot going on in that one sentence description.
"Just add a layer mask to your image and copy and paste your mask image into the layer mask, then save as a png."
I've opened the image, it shows as one layer labeled as {the filename}. I right-click on the layer, select "Add layer mask...", and 1/2 a shton of options appear.. which one to choose?
let's pick the alpha one ..continuing on..
Now the layer has two boxes on it, the image and the layer-mask.
"Just add a layer mask to your image and copy and paste your mask image into the layer mask, then save as a png."
So I can't just drag the mask-file into the layers.. I open the mask-file into a separate session/window so its by itself. I "Select> All" and then "Edit> Copy", it's now in the clipboard. Now.. "into the layer mask". How the heck do I paste into just the layer-mask portion of that layer?
Hmmm, I click on the the layer-mask box on the right of the two boxes on that layer, it's now got a white outline. Then I paste into what looks like a sea of alpha (because of my earlier choice)... and BAM! there it is! Now I exported as png. Done.
(I tried a few times and I actually didn't have this done and working until I went thru the exercise of recording this step by step.)

Thank You for stepping up and your help! There are so many options and capabilities in GIMP that it can be hard to know which to use and in what order and/or options. Again, Thank You.


Attachments:
File comment: The "Add a layer mask..." dialog box.
AddALayerMask.png
AddALayerMask.png [ 15.77 KiB | Viewed 3036 times ]
Top
 Post subject: Re: Clipping and Alpha using two generated source images
PostPosted: Sat May 30, 2020 8:15 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Apr 15, 2017
Posts: 1826
Glad you figured it out, I knew you would. I'm good at doing, but not so much at explaining.


Top
 Post subject: Re: Clipping and Alpha using two generated source images
PostPosted: Sun May 31, 2020 2:33 am  (#6) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2436
The small print: "File comment: Image file to be cleaned up by mask file, and alpha added.. eventually automated."

Easy enough one at a time....eventually automated ...is less easy.

It should be possible to write a Gimp script that will batch process pairs of images but a better tool for this is commandline Imagemagick (IM).

Still needs wrapping in a batch / bash file with file names replaced by variables, the basic command is

magick image-0007.png  image-0008.png -alpha Off -compose CopyOpacity -composite masked.png


gives this:

Attachment:
masked.jpg
masked.jpg [ 124.22 KiB | Viewed 2997 times ]


see: http://www.imagemagick.org/Usage/masking/#masks note: IM6 uses convert IM7 uses magick

_________________
Image


Top
 Post subject: Re: Clipping and Alpha using two generated source images
PostPosted: Sun May 31, 2020 5:15 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Apr 15, 2017
Posts: 1826
That's an interesting way to do it Rich. I'll bet that ffmpeg can do it too with the proper script. I still think its a lot easier to do it in Gimp, especially if you need to edit the mask.


Top
 Post subject: Re: Clipping and Alpha using two generated source images
PostPosted: Sun May 31, 2020 5:21 am  (#8) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2436
Agreed if you want to do one at a time.

There is a script that helps with the layer mask: One of Saul Goodes scripts copy-mask-from-above.scm

http://chiselapp.com/user/saulgoode/rep ... from-above

Does what it says. Saves having to - add layer mask / copy / paste / anchor

_________________
Image


Top
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Clipping groups

6

No new posts Attachment(s) Transparency not working on a PNG generated by PowerPoint

5

No new posts Sandboxie, soon, will be going Open Source.

7

No new posts Attachment(s) Kaleidoscope Plugin Source Code

1

No new posts Attachment(s) Source Code for all my GEGL Filters

35



* Login  



Powered by phpBB3 © phpBB Group