Scribusoid

Author Topic: cropping images to the visible part on export  (Read 157 times)

Dogil

  • Newbie
  • *
  • Posts: 33
  • Karma: 0
  • Scribus User
cropping images to the visible part on export
« on: November 22, 2021, 06:30:46 pm »
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

  • Full Member
  • ***
  • Posts: 130
  • Karma: 0
  • Active Scribus Mac User
    • architectural, industrial and business photographer
Re: cropping images to the visible part on export
« Reply #1 on: November 24, 2021, 01:55:51 pm »
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.

Nur wenige wissen, wie viel man wissen muss, um zu wissen, wie wenig man weiss.
Only few know how much you have to know to know how little you know.
Sólo unos pocos saben lo mucho que hay que saber para saber lo poco que se sabe.

— Werner Heisenberg [German theoretical physicist]

Nermander

  • Hero Member
  • *****
  • Posts: 1468
  • Karma: 19
Re: cropping images to the visible part on export
« Reply #2 on: November 26, 2021, 06: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.

Dogil

  • Newbie
  • *
  • Posts: 33
  • Karma: 0
  • Scribus User
Re: cropping images to the visible part on export
« Reply #3 on: November 26, 2021, 08:19:40 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

  • Newbie
  • *
  • Posts: 33
  • Karma: 0
  • Scribus User
Re: cropping images to the visible part on export
« Reply #4 on: November 27, 2021, 12:43:16 am »
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

  • Hero Member
  • *****
  • Posts: 1468
  • Karma: 19
Re: cropping images to the visible part on export
« Reply #5 on: November 28, 2021, 12:38:25 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

  • Newbie
  • *
  • Posts: 33
  • Karma: 0
  • Scribus User
Re: cropping images to the visible part on export
« Reply #6 on: November 30, 2021, 06:07:17 pm »
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