Solved

Using PHP, how do I create a random collage of images, all of different sizes?

Posted on 2008-10-08
6
421 Views
Last Modified: 2013-12-25
I need to create a collage/cloud type page of all images. I have an array filled with 10 different size combinations. Check out the image i made of the random sizes and distribution that this script needs to produce. I am wondering if someone knows of where i can find a script to produce something like the image i attached, or if there are guiding principles (css float, position, etc) that i need to fool around with first. I apologize for how vague I am being.
cats.jpg
0
Comment
Question by:jonarc124
6 Comments
 
LVL 39

Expert Comment

by:Roger Baklund
Comment Utility
You can use the PHP function imagecopyresampled() to copy and resize an image. You can resize multiple images (or multiple versions of the same image) into the same destination image.

http://php.net/manual/en/function.imagecopyresampled.php
0
 

Author Comment

by:jonarc124
Comment Utility
The php script needs to automatically place the different images, not resize them to fit one specific collage layout.
0
 
LVL 29

Expert Comment

by:fibo
Comment Utility
In the example you give:
- is it created from a single image, which is resized to fit? or is it supposed to be different images (minimum number?), each with a different size (which range of sizes?)
- Do you need taht all images somehow fill in the screen with no space, or is it totally random, eg as in the (blurred) capture attached?
screen-capture.jpg
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:jonarc124
Comment Utility
Different images (list pulled from a db with each image having different dimensions) filling the screen with no/minimal space in between each.  They can either fill the page from top left to bottom right, or kind of "grow" from the center of the page outwards.
0
 
LVL 29

Accepted Solution

by:
fibo earned 500 total points
Comment Utility
The optimum is a difficult algorithm. You might explore what is used for some machine tools which try to optimize how to "best" cut a set of pieces in a given dimension.

So you might consider which is your "second best" option, ie relax some constraints.

Interesting topological problem... explore mathematical sources...
0
 
LVL 4

Expert Comment

by:Lordgobbledegook
Comment Utility
In regards to image manipulation, Imagemagick is very widely used and highly regarded.  Most web hosts have it installed as standard.

I have found this link invaluable when working with image manipulation:
http://www.imagemagick.org/Usage/thumbnails/
and for all the topics... http://www.imagemagick.org/Usage/

While not directly related, there is also some interesting reading at:
http://valokuva.org/

It could also be done using GD within PHP but after using Imagemagick I find it to be clunky and inefficient.  All the best!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to count occurrences of each item in an array.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now