cropping images to the visible part on export

Previous topic - Next topic

Dogil

Do you have ideas how to crop images in PDFs when exporting (or later)?
https://graphicdesign.stackexchange.com/questions/154787/is-there-an-automated-way-to-remove-cropped-out-regions-of-embedded-images-in-or
I's been discussed here and the mailinglist before but maybe things have changed since.

toyotadesigner

Select the image.

Go to Image Properties. Select Free Scaling. Drag the handles to the place where you want to have the image boundaries.

Remain in Image Properties. Go to X-Pos and Y-Pos. Modify the values until the image fits your needs. You can also scale the image with the X-Scale (don't forget to lock the image ratio with the chain icon next to these values).

If everything looks great, generate a PDF.

To prevent image theft and if you don't want to print the PDF, you can to the export dialog and there to Security, place a checkmark into Use Encryption and submit a password two times. The nobody can extract your images, if you DESELECT the options as shown below.



[attachment deleted by admin]

Nermander

The issue has been discussed before and for JPEG images you get a quality loss (due to re-compression) if the cropping is not done in multiples of 16 pixels or something like that.

So cropping JPEG images is not trivial if you want to avoid quality losses.

Dogil

Quote from: Nermander on November 26, 2021, 05:38:42 PM
The issue has been discussed before and for JPEG images you get a quality loss (due to re-compression) if the cropping is not done in multiples of 16 pixels or something like that.

So cropping JPEG images is not trivial if you want to avoid quality losses.

I'm quoting Peter Nermander from 11 Years ago:
"The way a JPEG is compressed it has to be recompressed after any
change. Change one pixel and the image has to be recompressed. That is
why using JPEG as a working format during image editing is no good.

It seems however it is possible to do lossless cropping if you crop
along the borders of the "blocks" the image is made up of.

And if that is true that would probably be a working solution.It would
of course mean that the cropped images might become a little bigger
than the frame, but not more than 30 pixels (assuming worst case with
16 pixel blocks, giving 15 pixels on each side)."
https://scribus.scribus.narkive.com/9MO4dPPP/image-cropping#post4

Dogil

If I may add: I feel like the quality-loss-by-image-recompression argument is moot because:
1. you should work with lossless compression formats anyway
2. if the loss in quality becomes visible, you already have not enough resolution or a too high compression rate set.
3. you could just crop on block boundaries as detailed above.
4. if you have a pdf which is too large because of large but only partially visible images, you have the choice over saving the whole image in a crap resolution or cropping the small part which you actually need. Re-compression artifacts will be the lesser evil by far in this case.

Nermander

Quote from: Dogil on November 26, 2021, 11:43:16 PM
If I may add: I feel like the quality-loss-by-image-recompression argument is moot because:
1. you should work with lossless compression formats anyway
2. if the loss in quality becomes visible, you already have not enough resolution or a too high compression rate set.
If the function was implemented not considering this, the forums would be flooded by users complaining that their JPEG images look crappy in the PDF (becuase they are not aware of that ticking the "crop images to fram" function will suck on their from camera JPEG images).

Quote
3. you could just crop on block boundaries as detailed above.
Yes, but that should then be automatic within the function. Scribus in Open Source, anyone can contribute to the function.

Dogil

GhostScript devs say this functionality will not be implemented in GS:

"This isn't really feasible. There is no way to know, at the time the image is encoutnered, what portion of it will eventually be visible.

This problem is compounded by the PDF transparency model, we really can't tell whether the portion of the image lying under another object is obscured or contributes to the rendering of that object.

With a great deal of analysis I'm sure this is technically possible, but it would almost certainly require a two pass approach (at least) to identify the Z order of each object, and to determine whether the transparency in force at the time obscrued the underlying image or not.

I'm afraid this is far too much work for what I would have to say is a minority feature"

https://bugs.ghostscript.com/show_bug.cgi?id=704742