Discussion:
[scribus] Image cropping
Peter Nermander
2011-03-02 06:45:03 UTC
Permalink
Not sure where my mail from my phone went. It should be an option on PDF
export, hard coded into the export process, and definitely not a script.
There are a number of issues that need to be considered like how many
times any one particular image is used in a document etc.
Yes, if an image is re-used, it might make sense to only include it
once in the PDF.

But if JPEGs are going to be cropped at export, where do we set the
JPEG compression and similar parameters? Two users will not have the
same preference, so it must be a setting that can be changed. Global
and/or per image? All image formats with lossy compression would need
to be addressed. For other image formats the function could probably
use the same properties as in the original image.

I really think it might be better to include it in the pre-flight
check. A warning if less than a chosen percentage of an image is
shown? Default setting could be maybe 90%? So if less than 90% of an
image is visible in an image frame you will get a warning?

Maybe add cropping as an image effect? Then the user will have
several options. Leave the image uncropped, crop it (at export) with
image effect or open it with image editing software and crop it
manually.

/Peter
a.l.e
2011-03-02 09:27:33 UTC
Permalink
hi peter,
Post by Peter Nermander
But if JPEGs are going to be cropped at export, where do we set the
JPEG compression and similar parameters? Two users will not have the
same preference, so it must be a setting that can be changed. Global
and/or per image? All image formats with lossy compression would need
to be addressed. For other image formats the function could probably
use the same properties as in the original image.
craig's proposal is to crop the image which is put inside the PDF, not the one which is on your hard disk
Post by Peter Nermander
I really think it might be better to include it in the pre-flight
check. A warning if less than a chosen percentage of an image is
shown? Default setting could be maybe 90%? So if less than 90% of an
image is visible in an image frame you will get a warning?
nice idea! can you add it as a feature request in the bug tracker?
Post by Peter Nermander
Maybe add cropping as an image effect? Then the user will have
several options. Leave the image uncropped, crop it (at export) with
image effect or open it with image editing software and crop it
manually.
in my eyes, leaving it uncropped in the pdf does not make much sense (expect making the process much easier for the programmers: that's why scribus currently does it that way!)

but, as i said, it would be nice to have a script which helps the user to crop the image to the size of the frame (and it should give the option to overwrite the linked image or to create a new cropped image, leaving the original untouched).

ciao
a.l.e
Peter Nermander
2011-03-02 09:45:10 UTC
Permalink
This post might be inappropriate. Click to display it.
a.l.e
2011-03-02 11:20:04 UTC
Permalink
hi peter,
Post by Peter Nermander
Post by a.l.e
Post by Peter Nermander
But if JPEGs are going to be cropped at export, where do we set the
JPEG compression and similar parameters? Two users will not have
the same preference, so it must be a setting that can be changed.
Global and/or per image? All image formats with lossy compression
would need to be addressed. For other image formats the function
could probably use the same properties as in the original image.
craig's proposal is to crop the image which is put inside the PDF,
not the one which is on your hard disk
But that doesn't change the matter. People want to have control over
the quality of the image that gets embedded.
Also, cropping 10% of the sides but saving with less JPEG compression
then the original might make the file bigger! (It has happened to me,
camera was set to "Normal" image quality but GIMP was set to very low
compression. After cropping the image the file was like twice as big
as the original...)
probably, now i understand what you concern is...

afaik, cropping a jpeg is a lossless operation: so there is no change between the original image and the cropped one in the pdf...
or, at least, it can be done in a lossless way and without resampling it.
gimp, as an interactive application won't do it in a lossless way.
Post by Peter Nermander
Post by a.l.e
but, as i said, it would be nice to have a script which helps the
user to crop the image to the size of the frame (and it should give
the option to overwrite the linked image or to create a new cropped
image, leaving the original untouched).
Yes, but I guess that can be solved by anyone a bit fluent in
scripting.
probably, the scripter has first to be patched to implement it. currently, getImageScale() does not return the correct value and it's not possible to know which part of the image is shown in the frame.


ciao
a.l.e
Gregory Pittman
2011-03-02 13:51:02 UTC
Permalink
Post by Peter Nermander
Post by a.l.e
Post by Peter Nermander
But if JPEGs are going to be cropped at export, where do we set the
JPEG compression and similar parameters? Two users will not have the
same preference, so it must be a setting that can be changed. Global
and/or per image? All image formats with lossy compression would need
to be addressed. For other image formats the function could probably
use the same properties as in the original image.
craig's proposal is to crop the image which is put inside the PDF, not the one which is on your hard disk
But that doesn't change the matter. People want to have control over
the quality of the image that gets embedded.
There are some settings in the PDF export dialog:

http://wiki.scribus.net/canvas/Image_DPI_and_Scaling,_and_Resultant_File_Sizes#Another_Method

but one issue I see is that the settings apply to all images, and one
can certainly imagine that one might want different image quality for
various images in a PDF.

Greg
a.l.e
2011-03-02 14:23:52 UTC
Permalink
hi
Post by Gregory Pittman
http://wiki.scribus.net/canvas/Image_DPI_and_Scaling,_and_Resultant_File_Sizes#Another_Method
but one issue I see is that the settings apply to all images, and one
can certainly imagine that one might want different image quality for
various images in a PDF.
done. in 1.5 you can set the image quality for each image (on top of the global setting).

ciao
a.l.e
Louis Desjardins
2011-03-02 14:55:19 UTC
Permalink
2011/3/2 a.l.e <ale.comp_06 at xox.ch>
Post by Gregory Pittman
hi
http://wiki.scribus.net/canvas/Image_DPI_and_Scaling,_and_Resultant_File_Sizes#Another_Method
Here is more info.
http://kb2.adobe.com/cps/331/331327.html

Louis
Post by Gregory Pittman
Post by Gregory Pittman
but one issue I see is that the settings apply to all images, and one
can certainly imagine that one might want different image quality for
various images in a PDF.
done. in 1.5 you can set the image quality for each image (on top of the global setting).
ciao
a.l.e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.info/pipermail/scribus/attachments/20110302/f1a187b3/attachment.htm>
Peter Nermander
2011-03-02 19:36:13 UTC
Permalink
Post by a.l.e
afaik, cropping a jpeg is a lossless operation: so there is no change between the original image and the cropped one in the pdf...
or, at least, it can be done in a lossless way and without resampling it.
Yes, it can be done without resampling, but not without recompression.

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).

/Peter
Louis Desjardins
2011-03-02 21:12:41 UTC
Permalink
2011/3/2 Peter Nermander <peter at nermander.se>
Post by a.l.e
Post by a.l.e
afaik, cropping a jpeg is a lossless operation: so there is no change
between the original image and the cropped one in the pdf...
Post by a.l.e
or, at least, it can be done in a lossless way and without resampling it.
Yes, it can be done without resampling, but not without recompression.
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.
Hi,

Below is an excerpt from the GIMP's devs mailing list, a post by ?yvind K.
followed by a link leading to a page that is worth reading too.

Cheers!

Louis

JPEG is a lossy format, to be able to describe what happens when you do this
is
outlined in steps below:

1.1) The camera sensor provides the original image signal (pixel raster)
1.2) The camera performs white balance adjustment according to
setting/automatically determined white point
1.3) The camera does jpeg compression on the signal, discarding pieces
of the actual content
of the image in a perceptually little degrading manner. (removing
color resolution and keeping luminance information and giving
preferential room for certain spatial frequencies (DCT quantization.).
2.0) GIMP decodes JPEG trying to reconstruct the signal from 1.2 based
on the bits actually provided by 1.3.
2.1) Levels adjustment
2.2) Curves
2.3) Colors
2.4) The image is scaled actually improving the amount of data since
we're now approximating the original signal at this scale better (more
compressed bits per pixel).
2.5) The image is saved as JPEG throwing away information in the same
manner as 1.3 but
with different thresholds for how much precision should be maintained.
3.0) The image is loaded in GIMP or an other application in the same
manner as 2.0, trying
to reconstruct as signal based on not quite precise knowledge.

GIMP could perhaps even warn a user the first time he presses Ctrl+S
on a an opened JPEG image warning him that even with minimal or no
real changes to the image the signal will be degraded. This should be
a warning of such a level of non-expertise that it perhaps could be
turned on in the configuration/one of the initial tips of the day. And
for each of them of course have the ability to say do not show this
warning again.

Ideally JPEG compression involves a human operator that decides what
acceptable loss is through visual inspection. A power user GUI for
doing this would probably allow you to switch
between the full signal and a reconstructed one in the viewport,
perhaps with a zoomed in view with enlarged pixels in the dialog
itself that can be panned, but uses the center of the
image by default. The inputs needed in such a dialog would probably be
a target file size
entry (I often aim to make JPEG images ~100kb at web publishing
resolutions.) I would then
consider whether I've actually lost too much information and increase
the quality until I find it acceptable. For my use of this slider I do
not even need values of 0 and 100, I would actually expect 0.0 to
yield a completely grey image if it should make intuitive sense, keep
0% of the signal vs keep 100%. A scale going from low to high quality
makes more sense than any numerical values, like many other sliders it
makes sense to be able to tweak a transfer function to make the
results of interaction perceived as more uniform (another examples is
gaussian blur where you do not want a linear scale of the radius,
since that would give you a poor selection of smaller radiuses where
small differences matter more than in the large part of the sliders
range.)

A more immediate simpler enhancement is probably to use a higher
quality/produce larger files by default. I haven't taken the time to
do comparisons of how much is information is thrown away at each
generation of save, but it seems to be quite a bit, the image used in
the "JPEG Generation Loss" figure in the example in the following text
uses an image that
shows how JPEG compression keeps different aspects of the image intact
across multiple encode/decode cycles:

http://pippin.gimp.org/image_processing/chap_dir.html#id2526295

/?yvind K.
Post by a.l.e
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).
/Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.info/pipermail/scribus/attachments/20110302/32a7665a/attachment.htm>
a.l.e
2011-03-02 22:21:10 UTC
Permalink
hi


http://www.gsp.com/cgi-bin/man.cgi?section=1&topic=jpegtran

"""
We also offer a lossless-crop option, which discards data outside a given image region but losslessly preserves what is inside. Like the rotate and flip transforms, lossless crop is restricted by the current JPEG format: the upper left corner of the selected region must fall on an iMCU boundary. If this does not hold for the given crop parameters, we silently move the upper left corner up and/or left to make it so, simultaneously increasing the region dimensions to keep the lower right crop corner unchanged. (Thus, the output image covers at least the requested region, but may cover more.)

The image can be losslessly cropped by giving the switch:
-crop WxH+X+Y
Crop to a rectangular subarea of width W, height H starting at
point X,Y.
"""

not sure if this is what we are looking for...

ciao
a.l.e
Louis Desjardins
2011-03-02 22:42:32 UTC
Permalink
2011/3/2 a.l.e <ale.comp_06 at xox.ch>
Post by a.l.e
hi
http://www.gsp.com/cgi-bin/man.cgi?section=1&topic=jpegtran
"""
We also offer a lossless-crop option, which discards data outside a given
image region but losslessly preserves what is inside. Like the rotate and
flip transforms, lossless crop is restricted by the current JPEG format: the
upper left corner of the selected region must fall on an iMCU boundary. If
this does not hold for the given crop parameters, we silently move the upper
left corner up and/or left to make it so, simultaneously increasing the
region dimensions to keep the lower right crop corner unchanged. (Thus, the
output image covers at least the requested region, but may cover more.)
-crop WxH+X+Y
Crop to a rectangular subarea of width W, height H starting at
point X,Y.
"""
not sure if this is what we are looking for...
As far as I can tell, this would be pretty much what we are looking for, at
least for most of the usage.

If an image is used more than once into a document and is also used at
various sizes, I guess the result would be as many cropped images as needed
to cover all the needs in that particular document.

What do the devs say? Is this usable, implementable, doable?

Louis
Post by a.l.e
ciao
a.l.e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.info/pipermail/scribus/attachments/20110302/b5432c2a/attachment.htm>
Loading...