View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0009799 | Scribus | public | 2011-03-04 11:18 | 2021-01-25 00:33 | |
Reporter | cezaryece | Assigned To | jghali | ||
Priority | normal | Severity | tweak | Reproducibility | N/A |
Status | assigned | Resolution | open | ||
Product Version | 1.4.0svn | ||||
Target Version | 1.5.4 | ||||
Summary | 0009799: [PATCH] autocroping images during PDF export | ||||
Description | Here is patch for automatically crop JPG (and only JPG) images if they are manually scaled. Patch is small but working well for me. Maybe there should an option in PDF Export dialogue for switching this feature on/off - I am not good enough in GUI and Preferences tasks in Scribus. Maybe my patch inspires somebody who improve it with GUI/Preferences and for other kind of files... | ||||
Tags | patch | ||||
Patch | Yes | ||||
|
autocrop_pdflib_core.patch (2,247 bytes)
Index: Scribus/scribus/pdflib_core.cpp =================================================================== --- Scribus/scribus/pdflib_core.cpp (wersja 16339) +++ Scribus/scribus/pdflib_core.cpp (kopia robocza) @@ -6702,6 +6702,7 @@ bool bitmapFromGS = false; bool isEmbeddedPDF = false; bool hasGrayProfile = false; + bool cropped = false; QString profInUse = Profil; int afl = Options.Resolution; double ax, ay, a2, a1; @@ -6882,6 +6883,25 @@ PDF_Error_ImageLoadFailure(fn); return false; } + + + if (extensionIndicatesJPEG(ext) && c->ScaleType) + { + //autocropping only for JPG images (till now) and for images with manually scaling settings + double xs = sx * c->pixm.imgInfo.xres/72; + double ys = sy * c->pixm.imgInfo.yres/72; + double w = (c->width()/72) * c->pixm.imgInfo.xres / xs; + double h = (c->height()/72) * c->pixm.imgInfo.yres / ys; + QRect cropBox(-x, y, w, h); + + QImage tempImage = img.qImage().copy(cropBox); + img = ScImage(tempImage); + x=0; y=0; + ImInfo.xa = x; + ImInfo.ya = y; + cropped = true; + } + if ((Options.RecalcPic) && (Options.PicRes < (qMax(72.0 / c->imageXScale(), 72.0 / c->imageYScale())))) { double afl = Options.PicRes; @@ -7170,7 +7190,8 @@ { if (((Options.UseRGB || Options.UseProfiles2) && (cm == PDFOptions::Compression_Auto) && (c->effectsInUse.count() == 0) && (img.imgInfo.colorspace == ColorSpaceRGB)) && (!img.imgInfo.progressive) && (!((Options.RecalcPic) && (Options.PicRes < (qMax(72.0 / c->imageXScale(), 72.0 / c->imageYScale())))))) { - jpegUseOriginal = true; + if (!cropped) + jpegUseOriginal = true; cm = PDFOptions::Compression_JPEG; } // We can't unfortunately use directly cmyk jpeg files. Otherwise we have to use the /Decode argument in image |
|
Assigning to Jean to review. I think I would prefer a ScImage::cropped(x,y,w,h) function than extra code in the PDF lib, so it can then be applied to all image types and the code can then be specific to image types as required. |
|
Jean can you please test? |
|
double xs = sx * c->pixm.imgInfo.xres/72; double w = (c->width()/72) * c->pixm.imgInfo.xres / xs; is the same as w = c->width()/sx; (where sx is c->imageXScale()) |
|
That would be great and contribute to have slightly lighter PDFs. |
|
Balpha also made a patch for this issue. It's in his bitbucket |
|
Does this work with images that have a rotation inside the frame? |
|
How can I test this? It's over five years old... |
|
This is still useful, isn't it? |
|
I think it is. For two reasons: 1. It will result in smaller PDFs when small crops of large source images are used. In some cases you may then email documents which were too large before. 2. There are privacy implications if the document publisher crops out a person - let's say a child - from an image, but the receiver of the PDF can simply extract the full image from the document sources. |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-03-04 11:18 | cezaryece | New Issue | |
2011-03-04 11:18 | cezaryece | File Added: autocrop_pdflib_core.patch | |
2011-03-21 07:14 | cbradney | Assigned To | => jghali |
2011-03-21 07:14 | cbradney | Status | new => assigned |
2011-03-21 07:18 | cbradney | Note Added: 0025870 | |
2011-04-16 09:26 | cbradney | Target Version | => 1.5.0 |
2012-06-14 21:30 | cbradney | Note Added: 0028138 | |
2012-11-11 21:32 | ale | Note Added: 0029190 | |
2013-01-23 07:03 | jghali | Relationship added | has duplicate 0011393 |
2013-05-09 10:07 | JLuc | Note Added: 0030144 | |
2014-04-04 15:16 | JLuc | Tag Attached: patch | |
2014-07-03 19:32 | Kunda | Target Version | 1.5.0 => 1.5.1 |
2014-10-24 23:00 | Kunda | Patch | => Yes |
2015-11-13 21:55 | Kunda | Note Added: 0037465 | |
2016-01-23 17:17 | cbradney | Target Version | 1.5.1 => 1.5.3 |
2016-05-28 20:25 | jghali | Relationship added | has duplicate 0014115 |
2016-05-29 02:35 | dogil | Note Added: 0041504 | |
2016-05-29 03:21 | dogil | Note Added: 0041513 | |
2016-05-29 08:06 | Kunda | Relationship added | related to 0009790 |
2016-12-08 22:04 | Kunda | Target Version | 1.5.3 => 1.5.4 |
2021-01-24 20:12 | oberten | Note Added: 0048751 | |
2021-01-25 00:33 | dogil | Note Added: 0048753 |