The most important improvemens are:
1/ We guarantee that the image will always show up, even if the conversion
failed, which is something that does happen with certain specific file
formats. We've introduced exception catching if these cases which makes
sure that at least you'll have the original image.
2/ default quality ratio is better then it used to be
I'm not completely sure also but I think we might have changed the output
format or made sure we keep the original format.
Indeed documentation would be great.
As for why it was not used in Curriki, I think it did not exist when most
of Curriki was developped. Also the issue with possible failures made it
dangerous to use when you don't control the images passed through the
system.
Ludovic
2012/2/14 Sergiu Dumitriu <sergiu(a)xwiki.com>
On 02/12/2012 05:54 PM, Paul Libbrecht wrote:
Hello fellow xwiki users,
we discovered recently the usage of the width parameter when delivering a
picture from an xwiki document attachment.
Surprisingly this is available in our production server, based on the
grumpy xwiki 1.5, but has not been used in the UI of Curriki which has,
however, been made by a team of XWiki SàRL originally.
Yes, this has been implemented for a very long time. If I remember
correctly, it might have been introduced even before 1.0, or at least very
soon after that.
- can someone describe me how this feature is working?
Basically, whenever an image download request is processed, the
ImagePlugin intercepts it via the downloadAttachment plugin SPI method,
and, if there are width or height request parameter, instead of serving the
original attachment, it will create a new fake attachment holding the
resized image.
- is the resulting downscaled image cached in file or in ram?
There's a filesystem cache for resized images, indeed, so that the same
file isn't scaled for each request. Still, when downloading a specific
image, it will be held in memory as any XWikiAttachment object.
- has there been a different implementation between the current xwiki
> (e.g. 3.4) and 1.5?
Yes, kind of. It used to be all in
https://github.com/xwiki/**
xwiki-platform/blob/**c9b8a703cff266363782eee623ff4e**
b61aad4b45/xwiki-core/src/**main/java/com/xpn/xwiki/**
plugin/image/ImagePlugin.java#**L165<https://github.com/xwiki/xwiki-plat…
the image scaling code has been moved out of the plugin, and is now in
https://github.com/xwiki/**xwiki-platform/blob/master/**
xwiki-platform-core/xwiki-**platform-oldcore/src/main/**
java/com/xpn/xwiki/internal/**plugin/image/**DefaultImageProcessor.java<…
call to this component is still in the plugin, though).
There have been a few changes and improvements between the two versions.
Besides the width and height parameters, now there's support for a
"quality" parameter, a number between 0 and 1 controlling the compression
quality for JPEG files, and a "keepAspectRatio" parameter which means that
in case both a width and a height are specified, the image will be scaled
with the same aspect ratio to fit within the specified width and height.
- except for the CPU hogging of computing the downscaled version, is
there any reason not to use this feature? (e.g.
RAM overloading?).
It should be used as much as possible. The only problems are the extra
storage needed for storing thumbnails, and the extra CPU time needed to
scale, or at least to access the cached file from the disk.
In recent versions this feature has been used more and more, so most
places where images are used at a different size should already be making
use of this feature.
thanks in advance
Paul
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
______________________________**_________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/**mailman/listinfo/users<http://lists.xwiki.org/m…