View Issue Details

IDProjectCategoryView StatusLast Update
0009745ScribusScripterpublic2011-03-07 19:13
Reporterale Assigned Tocbradney  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version1.4.0svn 
Target Version1.4.0Fixed in Version1.4.0svn 
Summary0009745: [patch] the return value of getImageScale() does not really make sense...
Descriptionif i execute getImageScale() for an image which has a scaling of

86.21%, 100.09%

(as shown in the PP), i get the following values

(0.20690844301396635, 0.24022420926197785)

it's probably related to 0007563
TagsNo tags attached.
Patch

Activities

cbradney

2011-02-13 21:52

administrator   ~0025579

It makes sense for what it returns, but no, its possibly useless to half the people that need it.

You can always look up the PP code for more clues.

imageXScaleSpinBox->setValue(scx * 100 / 72.0 * CurItem->pixm.imgInfo.xres);
imageYScaleSpinBox->setValue(scy * 100 / 72.0 * CurItem->pixm.imgInfo.yres);

getImageXScale, getImageYScale and getImageXYScale probably need adding that return the %

ale

2011-02-13 22:08

manager   ~0025580

as said in IRC: in my opinion getImageScale() is not returning the scale of the image but a value which relates to the scale.

this is a bug and should be fixed.

and since i don't really think that anybody is using the value returned by getImageScale() (how could he reliably be using it for anything else than comparing scaleX and scaleY?), i would not add three more function to do what getImageScale() should already do.

however: i will look at it.

ale

2011-02-14 07:03

manager  

cmdgetprop.patch (537 bytes)   
--- cmdgetprop.cpp	2011-02-14 08:06:00.777039925 +0100
+++ cmdgetprop.cpp~	2011-02-14 08:05:26.609040074 +0100
@@ -224,7 +224,7 @@
 	if(!checkHaveDocument())
 		return NULL;
 	PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
-	return i != NULL ? Py_BuildValue("(ff)", i->imageXScale(), i->imageYScale()) : NULL;
+	return i != NULL ? Py_BuildValue("(ff)", i->imageXScale() / 72.0 * i->pixm.imgInfo.xres, i->imageYScale() / 72.0 * i->pixm.imgInfo.yres) : NULL;
 }
 
 PyObject *scribus_getimgname(PyObject* /* self */, PyObject* args)
cmdgetprop.patch (537 bytes)   

ale

2011-02-14 07:06

manager   ~0025586

the patch attached makes getImageScale() return the actual scale of the image. if an image is scaled down to 2/3 you'll get 0.66, which matches the 66% shown in the PP.

ale

2011-02-17 08:23

manager   ~0025610

as discussed in the mailing list, imageScale() should be also patched... i'll try to do it during the weekend.

jghali

2011-02-17 12:07

administrator   ~0025611

scaleImage() must not be changed. It has been deprecated and superceeded by setImageScale() which use PP values. That's mentionned in 1.4.0svn docs.

ale

2011-02-18 20:54

manager   ~0025627

jean, i would agree with you if getScaleImage() was not returning the wrong value which, by chance, matches the wrong value used by scaleImage() but not the one expected by setScaleImage().

for this reason, people are currently using scaleImage() instead of setScaleImage (even if they know it's deprecated) and we would break their scripts by fixing only one of the two methods (as the example posted by josé to the ML shows).

personally, i'd like in the future to offer the two commands setScaleImage() and getScaleImage() and get them both to work like setScaleImage() is actually working.

that's why i'm for patching scaleImage(), too, even if it's deprecated.

cbradney

2011-02-18 21:39

administrator   ~0025628

We will match up the APIs to the internal ones.. imageXScale(), imageYScale(), and as we can return 2 items in scripter, imageXYScale, plus setImageXScale, setImageYScale, setImageXYScale

deprecation means out of use, not re-purposed. in 1.5.0.. scaleImage will go away.

ale

2011-02-20 09:18

manager   ~0025639

some points and i'll stop the discussion from my side:

- it's imo not a good idea to match the c++ and python API (returning a touple is a thing you expect from python but not from c++): imo the scripter should only have setImageScale() getImageScale().

- i don't want to repurpose scaleImage(), just fix it (even if it's deprecated): the parameter it's expecting is wrong. the goal was to fix the bug without breaking existing scripts.

since this proposal does not seem to be accepted, i suggest to leave the functions as they are in 1.4 and plan to add the following commands to scripter2:
- getImageXScale()
- getImageYScale()
- setImageXScale()
- setImageYScale()
eventually also
- getImageXYScale()
- setImageXYScale()
all those methods work with values which match the PP ones.
all other "Scale" methods are deprecated / removed.

ale

2011-03-02 15:54

manager   ~0025711

Here is how I adjust images to frame:

##########################
# Fit image to frame
##########################
SCALETOFRAME = 1
FREESCALE = 0
PROPORTIONAL = 1
DISTORTED = 0

def adjustImageToFrame(frame):
    """Adjust bitmap image to frame."""
    scribus.setScaleImageToFrame(SCALETOFRAME,DISTORTED,frame)
    s = *scribus.getImageScale(**frame)*
    m = max(s[0],s[1])
    scribus.setScaleImageToFrame(FREESCALE,PROPORTIONAL,frame)
    scribus.scaleImage(m,m,frame) # scaleImage depracated (?)

cbradney

2011-03-06 16:25

administrator   ~0025742

Thanks, committed to both Version135 and trunk

Issue History

Date Modified Username Field Change
2011-02-13 21:35 ale New Issue
2011-02-13 21:52 cbradney Note Added: 0025579
2011-02-13 22:08 ale Note Added: 0025580
2011-02-14 07:03 ale File Added: cmdgetprop.patch
2011-02-14 07:06 ale Note Added: 0025586
2011-02-14 22:02 ale Summary the return value of getImageScale() does not really make sense... => [patch] the return value of getImageScale() does not really make sense...
2011-02-16 22:38 cbradney Product Version 1.4.0 => 1.4.0svn
2011-02-16 22:38 cbradney Target Version => 1.4.0
2011-02-17 08:23 ale Note Added: 0025610
2011-02-17 12:07 jghali Note Added: 0025611
2011-02-18 20:54 ale Note Added: 0025627
2011-02-18 21:39 cbradney Note Added: 0025628
2011-02-20 09:18 ale Note Added: 0025639
2011-03-02 15:54 ale Note Added: 0025711
2011-03-06 16:25 cbradney Note Added: 0025742
2011-03-06 16:25 cbradney Status new => resolved
2011-03-06 16:25 cbradney Fixed in Version => 1.4.0svn
2011-03-06 16:25 cbradney Resolution open => fixed
2011-03-06 16:25 cbradney Assigned To => cbradney
2011-03-07 19:13 cbradney Status resolved => closed