Click here to get back home

How to join two images with 'GD::Image'

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
How to join two images with 'GD::Image' Francesco Moi 06-25-2007
Posted by Francesco Moi on June 25, 2007, 4:36 am
Please log in for more thread options


Hi.

I've got two images on my Hard Disk ('pic1.jpg' and 'pic2.jpg') and
would like to join them both into a unique one ('mypic.jpg').

Is it possible with 'GD::Image'? Thank you very much.


Posted by Gunnar Hjalmarsson on June 25, 2007, 5:49 am
Please log in for more thread options


Francesco Moi wrote:
> I've got two images on my Hard Disk ('pic1.jpg' and 'pic2.jpg') and
> would like to join them both into a unique one ('mypic.jpg').
>
> Is it possible with 'GD::Image'?

Which efforts did you make to find out before asking here?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Posted by Francesco Moi on June 25, 2007, 6:32 am
Please log in for more thread options


>
> Which efforts did you make to find out before asking here?

I've been browsing
http://search.cpan.org/dist/GD/GD.pm

I didn't find out anything about "joining two images".

I've been searching with Google:
- "join two images" GD::Image perl
- join images GD::Image perl


Posted by Martien verbruggen on June 25, 2007, 7:07 am
Please log in for more thread options


On Mon, 25 Jun 2007 10:32:09 -0000,
>>
>> Which efforts did you make to find out before asking here?
>
> I've been browsing
> http://search.cpan.org/dist/GD/GD.pm
>
> I didn't find out anything about "joining two images".

You seem to be making the assumption that "joining two images" is
somehow standard graphics terminology. It isn't as far as I know. I am
assuming that to "join" two images, to you, means displaying them side
by side?

The above link has the complete documentation for GD::Image. What you're
looking for, if the above assumption is right, is the copy() method.

Create a new image, large enough to hold the 'joined' result. Use the
copy() method to put the old images in the appropriate place. Maybe you
need copyMerge if you want them to overlap.

For more complex combination methods between images, you might want to
look at Image::Magick or maybe Imager.

Martien
--
|
Martien Verbruggen | The problem with sharks is that they are too
| large to get to the shallow end of the gene
| pool. -- Scott R. Godin

Posted by Dean Arnold on June 25, 2007, 12:14 pm
Please log in for more thread options


Francesco Moi wrote:
>> Which efforts did you make to find out before asking here?
>
> I've been browsing
> http://search.cpan.org/dist/GD/GD.pm
>
> I didn't find out anything about "joining two images".
>
> I've been searching with Google:
> - "join two images" GD::Image perl
> - join images GD::Image perl
>

You have a nomenclature issue: "joining two images" isn't
a very precise description. Presumably you either want to
(a) composite two images, one on top of the other, or (b)
tile the images side by side. If you want (b), see
GD::Tiler. If you want (a), *and* you don't want any alpha
channel effect (ie, semitransparent overlays), then you can
just copy each image into a an output image object. If you
want alpha channels, you may need to consider Imager or
ImageMagick. GD purports to have alpha channel support, but
I've never had much luck getting it to work.

Dean Arnold
Presicient Corp.

Similar ThreadsPosted
CAM::PDF and images February 23, 2006, 9:56 am
how to use ImageMagick to compare 2 images? September 3, 2004, 11:05 pm
Loading (from Internet), resizing and saving images March 22, 2005, 6:15 am
Converting images with padding or cropping on left and right September 23, 2007, 8:55 am
[RFC] GD-Image-CopyIFS May 14, 2005, 3:42 pm
image magick through apt-get November 27, 2004, 5:48 pm
image::grab January 4, 2005, 7:22 pm
[RFC] Image::Pngslimmer December 24, 2006, 3:34 pm
Image magick palette July 30, 2004, 9:16 pm
Image::Magick newbie September 5, 2005, 10:19 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap