Hello! I am trying to copy some image elements from a PDF imported into Inkscape (v1.4 on Manjaro), then paste them into a fresh document.
I imported the PDF page using the Cairo option.
(The 'internal' option fails to import these elements when I leave 'embed images' checked: they do not show up as objects, and the images themselves are missing from the Document Resources list. If I uncheck 'embed images' the same is true, but the import procedure does spit out the wanted images as files into the working directory, so it's somehow aware of them. Not sure why they don't appear in the object tree.)
With Cairo import I do get the elements as objects ('dude' and 'coin' below; please ignore 'dudecoin'. NB: I can't show the actual images as per forum copyright rules). The associated images are in the Document Resources and everything looks normal.
When I select the objects and copy/paste them to an empty document, for some the object will show up as intended, but for others the image will be replaced by a rectangle object (rect5 below). So copy/pasted 'dude' shows up as intended, but copy/pasted 'coin' is a blank object.
As a test I just directly copy/pasted 'dude image' and 'coin image', with nothing else, to the fresh document. Once again, 'dude image' arrives as an image and shows as expected, whereas 'coin image' arrives as the blank use2703>g5>rect5 structure.
I can't reproduce the problem here, but that's not surprising. The pdf specification is huge and allows many, many ways to compose an image on a page. There are some rare complex file structures that Inkscape can't properly parse and convert to svg. Also, some pdf generating applications don't fully comply with the specification
If you upload a sample pdf page, perhaps somebody here can offer a workaround.
As usual PDFs contain tons of masked and path clipped objects as indicated by the icons in the Layers and Objects panel. Perhaps "release clip" before copy+paste process.
Thank you Paddy_CAD and Polygon for your insights.
It looks like the problematic ones like 'coin', even though appearing as a single image, are really a composite mask/clip/blend thing, as you guys guessed. On a lark I tried opening the PDF in LibreOffice Draw, and there they each show as stacks of four bitmap images (the same as in Inkscape's Document Resources dialog) and two polygon shapes. Whereas the unproblematic ones like 'dude' are just a single bitmap with a clip image on top.
When I take the original bitmaps into Inkscape, overlay them and do some blend mode adjusting, then apply a clip, I get something close to the original. So problem sort of solved.
The problematic ones do not have clipping but they have a mask; if I do "release mask" a mask does 'come off', but the unmasked image is still actually a composite; and it looks fine, but won't copy/paste properly.
Tyler, thanks, I bet it falls under fair use, just some hobbying around.
But in order to pare the issue down, I investigated a bit using basic shapes. Seems like blending causes trouble. Here is what I found, in case it's useful for improving import in general.
In the attached SVG, produced in Inkscape, there are three objects:
a blue square PNG bitmap masked by a rounded rectangle
the same blue square bitmap with a black-to-white gradient bitmap on top in Multiply blend mode, these two grouped, then masked by the rounded rectangle
the same blue square bitmap with a black-to-white gradient bitmap on top in Normal blend mode ('no blending'), these two grouped, then masked by the rounded rectangle
If you export this to PDF (file also attached) and then Cairo-import that PDF back into Inkscape, the result is as with my original case. All three objects look fine. But when you copy/paste them to a fresh document, the second one with the Multiply blending has its bitmap replaced by a blank rectangle.
In this example case the internal import method does better, even though the objects appear with their masking rectangles color-inverted (rendering them almost invisible). If I release the mask, apply an Invert lightness color filter to it, then re-apply the mask, the resulting objects are again as in the original SVG; and they copy/paste fine to a fresh document.
For my original, much more complex PDF though, internal import results in multiple 'Group of 0 objects' groups (I suspect this is where the image objects should be) and some of the relevant bitmaps missing from the Document Resources (specifically, the 'base' bitmaps; the mask bitmaps are in fact present). The file is available here; the original issue is with the red 'dude' and 'coin' (seal, really) in the lower right quadrant of page 2.
I did some digging deeper, mot objects are images with clips and masks. The seal/coin is a whole different animal.Â
I repeatedly deleted a few objects and cleaned the file until only the seal was remaining. The code hidden in the "defs" section of the document is anything but a simple image... it has a complex filter structure.
So, it's not surprising to me that it would not simply copy/paste to a new document like the man-figurine. (that is accomplished by unlinking it, it is a clone).
But once it is isolated, It can be copied as a bitmap (Alt-B) and that bitmap can be clipped, copied and pasted.
Yes, you're right, expanding the def indicates there's other filters than blending going on too.
I hadn't noticed the copy-as-bitmap option. Wonderful! That simplifies everything :) It's awesome that transparency is preserved -- may not even need a mask that way.
The bitmap conversion does come with a loss in crispness. But this thread shows the way to increase the resolution: Preferences > Imported Images > Resolution for Create Bitmap Copy. If I set it to 200 dpi instead of 96 dpi, copy crispness approaches the original.
Many thanks Tyler! (And kudos on your profile message.)
Hello! I am trying to copy some image elements from a PDF imported into Inkscape (v1.4 on Manjaro), then paste them into a fresh document.
I imported the PDF page using the Cairo option.
(The 'internal' option fails to import these elements when I leave 'embed images' checked: they do not show up as objects, and the images themselves are missing from the Document Resources list. If I uncheck 'embed images' the same is true, but the import procedure does spit out the wanted images as files into the working directory, so it's somehow aware of them. Not sure why they don't appear in the object tree.)
With Cairo import I do get the elements as objects ('dude' and 'coin' below; please ignore 'dudecoin'. NB: I can't show the actual images as per forum copyright rules). The associated images are in the Document Resources and everything looks normal.
When I select the objects and copy/paste them to an empty document, for some the object will show up as intended, but for others the image will be replaced by a rectangle object (rect5 below). So copy/pasted 'dude' shows up as intended, but copy/pasted 'coin' is a blank object.
As a test I just directly copy/pasted 'dude image' and 'coin image', with nothing else, to the fresh document. Once again, 'dude image' arrives as an image and shows as expected, whereas 'coin image' arrives as the blank use2703>g5>rect5 structure.
Can somebody surmise what is going on?
Many thanks!
I can't reproduce the problem here, but that's not surprising. The pdf specification is huge and allows many, many ways to compose an image on a page. There are some rare complex file structures that Inkscape can't properly parse and convert to svg. Also, some pdf generating applications don't fully comply with the specification
If you upload a sample pdf page, perhaps somebody here can offer a workaround.
As usual PDFs contain tons of masked and path clipped objects as indicated by the icons in the Layers and Objects panel. Perhaps "release clip" before copy+paste process.
Thank you Paddy_CAD and Polygon for your insights.
It looks like the problematic ones like 'coin', even though appearing as a single image, are really a composite mask/clip/blend thing, as you guys guessed. On a lark I tried opening the PDF in LibreOffice Draw, and there they each show as stacks of four bitmap images (the same as in Inkscape's Document Resources dialog) and two polygon shapes. Whereas the unproblematic ones like 'dude' are just a single bitmap with a clip image on top.
When I take the original bitmaps into Inkscape, overlay them and do some blend mode adjusting, then apply a clip, I get something close to the original. So problem sort of solved.
The problematic ones do not have clipping but they have a mask; if I do "release mask" a mask does 'come off', but the unmasked image is still actually a composite; and it looks fine, but won't copy/paste properly.
It's copyrighted though (even if formerly freely available from the publisher)?
Â
Copyright can include freely licensed and fair use. If your uses are within those scopes, feel free to share here.Â
Tyler, thanks, I bet it falls under fair use, just some hobbying around.
But in order to pare the issue down, I investigated a bit using basic shapes. Seems like blending causes trouble. Here is what I found, in case it's useful for improving import in general.
In the attached SVG, produced in Inkscape, there are three objects:
If you export this to PDF (file also attached) and then Cairo-import that PDF back into Inkscape, the result is as with my original case. All three objects look fine. But when you copy/paste them to a fresh document, the second one with the Multiply blending has its bitmap replaced by a blank rectangle.
In this example case the internal import method does better, even though the objects appear with their masking rectangles color-inverted (rendering them almost invisible). If I release the mask, apply an Invert lightness color filter to it, then re-apply the mask, the resulting objects are again as in the original SVG; and they copy/paste fine to a fresh document.
For my original, much more complex PDF though, internal import results in multiple 'Group of 0 objects' groups (I suspect this is where the image objects should be) and some of the relevant bitmaps missing from the Document Resources (specifically, the 'base' bitmaps; the mask bitmaps are in fact present). The file is available here; the original issue is with the red 'dude' and 'coin' (seal, really) in the lower right quadrant of page 2.
There's a lot of stuff going on there. I only dug a little into it, and removed the top-level clipping objects.
If you use View>Display mode>Outline overlay, you can see which objects are clipped and/or masked, and/or images.
The svg file is too big to upload here, so I put it here:Â https://drive.google.com/file/d/1NLswnmtRpLfVE1jleMrJ7HQDDrz3dQ1W/view?usp=sharing
I'd continue to pick it apart and remove all clips, masks and their respective clip/mask objects.
Depending on your end-use, your work might be covered under fair use, but if you are making stuff to sell or share, get permission from the creators.
Â
I did some digging deeper, mot objects are images with clips and masks. The seal/coin is a whole different animal.Â
I repeatedly deleted a few objects and cleaned the file until only the seal was remaining. The code hidden in the "defs" section of the document is anything but a simple image... it has a complex filter structure.
So, it's not surprising to me that it would not simply copy/paste to a new document like the man-figurine. (that is accomplished by unlinking it, it is a clone).
But once it is isolated, It can be copied as a bitmap (Alt-B) and that bitmap can be clipped, copied and pasted.
Â
Â
Yes, you're right, expanding the def indicates there's other filters than blending going on too.
I hadn't noticed the copy-as-bitmap option. Wonderful! That simplifies everything :) It's awesome that transparency is preserved -- may not even need a mask that way.
The bitmap conversion does come with a loss in crispness. But this thread shows the way to increase the resolution: Preferences > Imported Images > Resolution for Create Bitmap Copy. If I set it to 200 dpi instead of 96 dpi, copy crispness approaches the original.
Many thanks Tyler! (And kudos on your profile message.)
Â