Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

My challenge: combine two images into one. Advice appreciated!


Go to End


3 Posts   1219 Views

Avatar
Wilson

Community Member, 63 Posts

28 October 2010 at 9:24am

Hi everyone,

My client would like to be able to upload two images and have them combined into one. For example, two individual magazine pages combined into one spread.

I have all of the PHP written to do this, and would very much appreciate any advice on how/where to incorporate this into DOM/Uploadify workflow, of course, without touching the core of either.

I'm planning that there will be three db fields, 'image1', 'image2' and 'combinedImage' (something along these lines), so image1 and image2 are never destroyed. Then 'onSave', combine them into one image and save into the 'combinedImage' field.

Thanks in advance for your time.

Best,
Wilson

Avatar
bummzack

Community Member, 904 Posts

28 October 2010 at 11:03am

I don't know where your two source images are coming from (are they part of the same DataObject)? A good place to do things like this would be in the onAfterWrite method of your DataObject.
To avoid rendering of the image every time you save the DataObject, you could compose the name of the image from the two IDs of the source images (eg. composite_idA_idB.jpg) and check if such a file already exists. If the file exists, you're done, otherwise the composite image doesn't exist yet and can be created.

Avatar
Wilson

Community Member, 63 Posts

28 October 2010 at 6:01pm

Thanks banal! Yes, both images are part of the same DataObject. That sounds like a good plan. Much appreciated.