Jump to content

Archived

This topic is now archived and is closed to further replies.

gerkintrigg

Image Manipulation Using The Gd Library

Recommended Posts

I'm trying to work out how to resize my image.

I have the following code, which writes my copyright notice across the image (this is for an image bank) but I'd also like to add a watermarked logo to the image aswell as resize the final image.

I tried everything I can think of but the only working version I have (which doesn't do everything I'd like) is this:

[code]<?php

// Set dimension of image
$Height = 200;
$Width= 300;

// Now make it
$im = ImageCreateFromGif($root.$img_details['url']);
$White = ImageColorAllocate ($im, 100, 100, 100);
$Blue = ImageColorAllocate ($im, 0, 0, 64);

// Resize it:
//$im = ImageCopyResized($Width,$Height);

// draw on image
ImageFill ($im, 0, 0, $blue);
ImageLine ($im, 0, 0, $Width, $Height, $White);
ImageString($im, 11, 2, 5, 'Copyright Protected', $White);
ImageString($im, 11, 2, 25, 'By Next Day Graphics', $White);
ImageString($im, 11, 2, 45, 'Sample Only', $White);

// output image
ImagePng ($im);

// clean up
ImageDestroy($im);?>[/code]

Share this post


Link to post
Share on other sites

×

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.