Jump to content

Overlapping images with GD


azuka

Recommended Posts

I'm currently working on a website and had to write a joomla component to display videos [ see http://webdd.org/i55.org/index.php?option=com_experience&Itemid=29 ].

The client wanted to be able to upload a picture, have it resized and super-impose it on a bg, and add an arrow over the entire image. Please look at the above site in Firefox.

I had problems getting the last image [ a transparent png file ] added to the image as the arrow part got colored according to the image underneath it. I decided to use the CSS hack, but since it's buggy in IE, I'm going back to the GD approach. Please advice me on this bit of code:

[code]<?php
//...some code before this

$comp_dir = $mosConfig_absolute_path . '/administrator/components/com_experience/images/video-';

$filename = $dest_dir . strtolower($file['name']); // uploaded file

$image = imagecreatefrompng( $comp_dir . 'bg.png' ); // base bg
$arrow = imagecreatefrompng( $comp_dir . 'arrow.png' ); //arrow file
$src = imagecreatefromjpeg( $filename ); //uploaded file


//imageAlphaBlending($arrow, false); //tried this
//imageSaveAlpha($arrow, false);    //and this -- didn't work

$img_info = getimagesize($filename);

//resize uploaded image ($src) and place on bg ($image)
imagecopyresampled( $image, $src, 7, 8, 0, 0, 74, 66, $img_info[0], $img_info[1] );

//place arrow at position, 69, 60 on $image
imagecopyresampled( $image, $arrow, 69, 60, 0, 0, 20, 23, 20, 23) ;

unlink($filename); //delete uploaded file


imagejpeg( $image, $filename ); // output jpeg file to $filename

imagedestroy($image); //destroy
imagedestroy($src); //all
imagedestroy($arrow); //resources
//... some code after this

?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.