[opencms-dev] CmsImageScaler and PNGs
Steve Bryan
steve at bright-interactive.com
Mon Sep 27 17:48:24 CEST 2010
Hi Roman
Thanks for responding to my post! It's a png-24 image.
While posting the PNG and code online I have discovered that exactly the
same PNG and code works on 7.5.2 but not on 7.5.1!
I haven't got any online sites with version 7.5.1, but I posted the image
and some code to render it on a 7.5.2 site at:
http://www.discover-the-world.co.uk/school/trip/template/test/test.jsp
Using Firefox firebug I can see that on this 7.5.2 site the image source is
being scaled down from 69x69 to 50x50 properly by the opencms scalar.
However if I port the same jsp and png into my 7.5.1 site, then the image
source is shown by Firebug to be still 69x69.
Very strange, perhaps the OpenCms devs fixed something in CmsImageScalar in
7.5.2???
Anyway, this could be a dead end but I thought I would post my findings in
any case, in case anyone has a similar problem with 7.5.1.
Regards
Steve
test.jsp
<%@ page import="java.util.*,
org.opencms.jsp.*, org.opencms.loader.*,
org.opencms.file.*" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<p>Raw image (69x69):<br/>
<img src="<cms:link>/template/test/test-png-icon.png</cms:link>" />
</p>
<p>Using standard image height and width attributes (50x50):<br/>
<img src="<cms:link>/template/test/test-png-icon.png</cms:link>" height="50"
width="50" />
</p>
<p>Using OpenCms cms:img tag (scaled to 50x50):<br/>
<cms:img src="/template/test/test-png-icon.png" height="50" width="50"
scaleType="1" />
</p>
<p>Using OpenCms cms.img api(scaled to 50x50):<br/>
<%
// Scaler properties
CmsJspActionElement cms = new CmsJspActionElement(pageContext,
request, response);
CmsImageScaler scaler = new CmsImageScaler();
scaler.setHeight(50);
scaler.setWidth(50);
scaler.setType(1);
%>
<%= cms.img( "/template/test/test-png-icon.png", scaler, new HashMap())
%>
</p>
-----Original Message-----
We scale PNG images through OpenCms without any problems.
Is your image PNG-8 or PNG-24? (or post a link to the image)
Roman
steve bryan wrote:
>
> Hi
>
> I'm using the CmsImageScaler API in a reasonably standard way. It does
> resize JPGs fine but doesn't seem to make PNGs any smaller (they remain
> the
> original size with just reduced height and width attributes).
>
> I thought the scaler handled PNGs. Does it not, or am I doing something
> wrong?
>
> Rendered source is as follows:
>
> /xxx/sample.png?__scale=w:57,h:57,c:transparent,q:100
>
> If the file is sample.jpg then it is reduced in size to 57x57, but the png
> remains it's original size.
>
> Thanks
> Steve
>
>
*******************************************
More information about the opencms-dev
mailing list