View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0009745 | Scribus | Scripter | public | 2011-02-13 21:35 | 2011-03-07 19:13 |
Reporter | ale | Assigned To | cbradney | ||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 1.4.0svn | ||||
Target Version | 1.4.0 | Fixed in Version | 1.4.0svn | ||
Summary | 0009745: [patch] the return value of getImageScale() does not really make sense... | ||||
Description | if 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 | ||||
Tags | No tags attached. | ||||
Patch | |||||
|
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 % |
|
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. |
|
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) |
|
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. |
|
as discussed in the mailing list, imageScale() should be also patched... i'll try to do it during the weekend. |
|
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. |
|
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. |
|
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. |
|
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. |
|
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 (?) |
|
Thanks, committed to both Version135 and trunk |
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 |