<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.apple-tab-span
{mso-style-name:apple-tab-span;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NO-BOK link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi again Henning and list, <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>That post was very interesting indeed, thanks! What Alexander says here would be *perfect*:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>“If you set the property "image.size" on a folder, all images uploaded to this folder are scaled automatically to that size after the upload.” (paraphrased)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>However, I cannot get it working like this. I tested on v7 & v8 by setting “w:100,h:100,t:3,q:100” as value for the “image.size” property on the gallery folder. (It could be just the syntax, but I tried various other forms and none worked. Also, looking at the CmsImageScaler#parseParameters source, the mentioned syntax seems correct.) <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Maybe Alkacon dropped this sometime after v6.2 (which is the version Alex is talking about), but that seems strange...<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Anyone else got this working?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Cheers,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Paul<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> opencms-dev-bounces@opencms.org [mailto:opencms-dev-bounces@opencms.org] <b>On Behalf Of </b>Henning Treu<br><b>Sent:</b> 1. oktober 2013 14:03<br><b>To:</b> The OpenCms mailing list<br><b>Subject:</b> Re: [opencms-dev] Downscale large images automatically upon upload / create image resource<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi Paul,<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I found this in the archives: <a href="http://lists.opencms.org/pipermail/opencms-dev/2006q3/026284.html">http://lists.opencms.org/pipermail/opencms-dev/2006q3/026284.html</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Alexander describes how to automatically scale down images exceeding a certain size.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Cheers<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>Henning<o:p></o:p></p><div><div><p class=MsoNormal>On Oct 1, 2013, at 12:12 PM, Paul-Inge Flakstad <<a href="mailto:flakstad@npolar.no">flakstad@npolar.no</a>> wrote:<o:p></o:p></p></div><p class=MsoNormal><br><br><o:p></o:p></p><p class=MsoNormal>Hi Henning,<br><br>Thank you, this makes perfect sense. :)<br><br>(Being familiar with both the scaler and the event listeners, I should have thought of using a listener - it's quite obvious.)<br><br>But, anyway, I seem to recall reading about some native functionality in OpenCms which lets you set max image size. Not sure if my memory can be trusted though. <br><br>Can you (or anyone else) tell me anything about this?<br><br>Cheers,<br>Paul<br><br>-----Original Message-----<br>From: <a href="mailto:opencms-dev-bounces@opencms.org">opencms-dev-bounces@opencms.org</a> [mailto:opencms-<a href="mailto:dev-bounces@opencms.org">dev-bounces@opencms.org</a>] On Behalf Of Henning Treu<br>Sent: 1. oktober 2013 08:59<br>To: The OpenCms mailing list<br>Subject: Re: [opencms-dev] Downscale large images automatically upon upload / create image resource<br><br>Hi Paul,<br><br><br><o:p></o:p></p><p class=MsoNormal>If not, can I avoid touching core classes in OpenCms if I was to <br>create such functionality myself? (Or: Can I add-on a custom "create <br>image resource" handler class? How do I make OpenCms use it?)<o:p></o:p></p><p class=MsoNormal><br>there is a way to implement your own functionality like this. In manifest.xml there is an element <class> which lets you provide a full qualified class name for your custom implementation of I_CmsModuleAction. You can register event listeners in the initialize method and process EVENT_RESOURCE_CREATED events. Make sure to retain the admin CmsObject from the initialise method.<br>Something like this:<br><br>@Override<br>public void initialize(CmsObject adminCms, CmsConfigurationManager configurationManager, CmsModule module) {<br><span class=apple-tab-span> </span>CmsEventManager eventManager = OpenCms.getEventManager();<br><br><span class=apple-tab-span> </span>LOG.info("Registering cms event listeners:");<br><span class=apple-tab-span> </span>CCECmsEventListener listener = new MyCustomEventListener();<br><span class=apple-tab-span> </span>listener.setCmsObject(adminCms); // set the admin cms object for future use<br><span class=apple-tab-span> </span>eventManager.addCmsEventListener(listener, <br><span class=apple-tab-span> </span>new int[] { I_CmsEventListener.EVENT_RESOURCE_CREATED });<br><span class=apple-tab-span> </span>LOG.info(listener.getClass().getName() + " registered."); }<br><br>In your listener you might use the CmsImageScaler. Its quite easy to use. I do it like this:<br><br>private CmsImageScaler createImageScaler(int width, int height) {<br><span class=apple-tab-span> </span>CmsImageScaler scaler = new CmsImageScaler();<br><br><span class=apple-tab-span> </span>scaler.setWidth(width);<br><span class=apple-tab-span> </span>scaler.setHeight(height);<br><span class=apple-tab-span> </span>scaler.setType(3); // preserve aspect ratio<br><span class=apple-tab-span> </span>scaler.setRenderMode(Simapi.RENDER_QUALITY); // QUALITY or SPEED<br><span class=apple-tab-span> </span>scaler.setQuality(100); // JPEG compression quality<br><br><span class=apple-tab-span> </span>return scaler;<br>}<br><br><br>Cheers<br>Henning<br><br><br><br><o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Alternatively, is there a way to simply disallow upload of "large" (as defined by me) images?<br><br>Any advice is much appreciated! :)<br><br>Challenge: <br>Some editors don't bother to downscale images before uploading. This <br>is a problem, because although all our images are downscaled in-page, <br>we still link the in-page image to the original. Also, if the <br>resolution is really huge, we could run into out-of-memory situations <br>on the server when creating the downscaled versions displayed in-page <br>on the site. (Especially if OpenCms was to initiate multiple <br>downscales at roughly the same time - after flushing the image cache, <br>for example.)<br><br>Imagined solution:<br>Eliminate the problem by setting a max resolution for images. Possibly implemented by automatically downscaling large images upon upload / create. Ideally I should also be able to override the restriction on a per-folder basis, for those special cases when a high-res image is actually called for.<br><br>Cheers,<br>Paul<br><br>_______________________________________________<br>This mail is sent to you from the opencms-dev mailing list To change <br>your list options, or to unsubscribe from the list, please visit <br><a href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a><br><br><br><o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'><br>_______________________________________________<br>This mail is sent to you from the opencms-dev mailing list To change your list options, or to unsubscribe from the list, please visit <a href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a><br><br><br><br>_______________________________________________<br>This mail is sent to you from the opencms-dev mailing list<br>To change your list options, or to unsubscribe from the list, please visit<br><a href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a><br><br><br><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>