Jump to content

Simple Image .png Question


jmrosenwald

Recommended Posts

i cannot exactly tell what you mean but to display a different file if a php file is parsed you would do this:

 

<?php

$somefile = "image1.png";

$anotherfile = "image2.gif";

if($_FILES[$somefile]['type']=="image/png") {

print '<img src=' . $otherfile . ' />';

}

else {

print '<img src=' . $somefile . ' />';

}

?>

I can't figure out how to use that correctly.

Let me show you:

 

http://www.renaxgade.net/sigs/tictactoe.png

 

That is a board created from php. I want to display X's and O's on it (jpg's) if the right get variable is passed.

 

imagecopyresized($image, "http://renaxgade.net/sigs/x.jpg", 0, 0, 0, 0, 108, 108, 432, 432);

 

So 108x108 = size of image I want to import onto the bigger image, which is 432x432. It should place it at the top left corner.

However, I just get an error and it won't spit the image back.

 

Thanks again

Joe

  • 3 weeks later...

Try this code. It may be that the value of the source is broken somewhere so i laid it out nicely. It should create a new image called x_s.jpg in you source directory.

 

<?php
// The image sources
$dst_image = $_SERVER['DOCUMENT_ROOT'] . '/sigs/x_s.jpg';
$src_image = $_SERVER['DOCUMENT_ROOT'] . '/sigs/x.jpg';

// the destination coordinates
$dst_x = '0';
$dst_y = '0';

// the source coordinates
$src_x = '0';
$src_y = '0';

// the new image size
$dst_w = '108';
$dst_h = '108';

// the source image size
$src_w = imagesx($src_image);
$src_h = imagesy($src_image);

//the function
imagecopyresized($dst_image,$src_image,$dst_x,$dst_y,$src_x,$src_y,$dst_w,$dst_h,$src_w,$src_h );
?>

Archived

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

×
×
  • 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.