?
Solved

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

Posted on 2008-10-08
6
Medium Priority
?
670 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 22674579
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
ID: 22674613
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
ID: 22676387
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
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 

Author Comment

by:jonarc124
ID: 22679291
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 2000 total points
ID: 22693063
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
ID: 22711310
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

649 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