If you want to provide these new feature, yes why not create a Jira and attach 
a patch?

Jacques


Le 16/01/2015 09:52, Ingo Wolfmayr a écrit :
Hi Jacques,

yes. I am already testing my version - so from technical point of view it 
works. The question is if this is something that could be interesting for the 
content management part of the project as it is completely unrelated to 
products (as Image Management relies on a productId).

Used for news overviews, gallery thumbnails, image previews ...

Ingo


-----Ursprüngliche Nachricht-----
Von: Jacques Le Roux [mailto:jacques.le.r...@les7arts.com]
Gesendet: Freitag, 16. Jänner 2015 06:44
An: user@ofbiz.apache.org
Betreff: Re: Scale image (Content Management)

Did you have a look at 
http://demo-trunk-ofbiz.apache.org/catalog/control/Imagemanagement ?

Jacques

Le 15/01/2015 11:07, Ingo Wolfmayr a écrit :
Hi all,

I would like to share my thoughts on what I am currently working on with the 
hope to get  some input to have it done 100% Ofbiz style. Maybe this feature 
could be interesting for the project:

Goal: resize uploaded images to predefined scales (Content Management)
File representation:

Original ../ofbiz/runtime/uploads/11111111/10001.jpeg
Small ../ofbiz/runtime/uploads/11111111/SMALL/10001.jpeg
...

Reason: improve load time of page by reducing image size

How to:

Config:
- Define scales
- Turn feature on & off.

Create Service "createScalesFromUploadedImage" and add code to do the resize 
job.

Insert service in:
.. applications\content\servicedef

      <service name="createContentFromUploadedFile" engine="group" 
transaction-timeout="300">
          <description>Accepts file upload, creates DataResource and Content 
records.</description>
          <!-- uses createContent internally; additonal permission(s) not 
necessary -->
          <group>
              <invoke name="createDataResource" parameters="preserve" 
result-to-context="true"/>
              <invoke name="attachUploadToDataResource" parameters="preserve" 
result-to-context="true"/>
              <invoke name="createContentFromDataResource" parameters="preserve" 
result-to-context="true"/>
             <invoke name="createScalesFromUploadedImage"/>
          </group>
      </service>
      <service name="updateContentAndUploadedFile" engine="group" 
transaction-timeout="300">
          <description>Accepts file upload, updates DataResource and Content 
records.</description>
          <group>
              <invoke name="updateDataResource" parameters="preserve" 
result-to-context="true"/>
              <invoke name="attachUploadToDataResource" parameters="preserve" 
result-to-context="true"/>
              <invoke name="updateContent" parameters="preserve" 
result-to-context="true"/>
                        <invoke name="createScalesFromUploadedImage"/>
          </group>
      </service>


This works already using CMS. Creating an image by using "create content" seems 
to call different methods to upload the image. I still have to check why.

Adding an "ImageWorker" class to access the scaled images with methods
like " getImageScaleFromDataResource, getImageScaleFromContent ". I do
not thing they should be added to the database as dataresources as
they are just another representation of the original image. If the
image scale is not available it will be created on fly. If the
original image is there, there is no reason to result in 404. Service
to scale the image is called when
- uploading,
- updating,
- retrieved and file is not available.

Workflow to stream the image:

Call stream like: "stream?contentId=10001?scale=small"

"stream" --> DataEvents.serveObjectData

Add:
String imageScale = (String) httpParams.get("scale"); .
.
resourceData = ImageWorker. getImageScaleFromDataResource
(dataResource, https, webSiteId, locale, contextRoot, scale, false);

Then the image gets streamed.

I would appreciate any thoughts.

Ingo









Reply via email to