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
