Jump to content

Picture within a picture.. help


plznty

Recommended Posts

I want a picture to be shown withing another picture, the picture would have to be retrieved from a url.

For example

PICTURE.PHP -

A 100x100 black box

$url = file_get_contents("http://whereis.the/file/40x40.txt");

 

I want the url from $url to display within picture.php

 

Could anyone give me some helpful links etc thank you in advance

Link to comment
https://forums.phpfreaks.com/topic/189837-picture-within-a-picture-help/
Share on other sites

That's nice to know thanks..

 

Here is my Santa list:

 

I'll like to be paid more and have more time off and a bigger.. wallet!

EDIT:

ahh a question, okay do you want to add text to the picture ? (as you opening a text file ?)

if so look at imagettftext

as for image on/in image

imagecopymerge

ie

// Create image instances
$dest = imagecreatefromgif('php.gif');
$src = imagecreatefromgif('php.gif');

// Copy and merge
imagecopymerge($dest, $src, 10, 10, 0, 0, 100, 47, 75);

// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest);

imagedestroy($dest);
imagedestroy($src);

okay I have created a sample, that you will probably need to tweak, but it should get to started

 

<?php
$filename = "White-Cat.jpg";

$width = 100;
$height = 100;

list($width_orig, $height_orig) = getimagesize($filename);

$ratio_orig = $width_orig/$height_orig;

if ($width/$height > $ratio_orig) {
   $width = $height*$ratio_orig;
} else {
   $height = $width/$ratio_orig;
}

// Create image instances
$src = imagecreatefromjpeg($filename);
$dest = imagecreatetruecolor($width+20, $height+40);

// Resample
imagecopyresampled($dest, $src, 10, 10, 0, 0, $width, $height, $width_orig, $height_orig);


//text
$black = imagecolorallocate($dest, 0xFF, 0xFF, 0xFF);
$font_file = 'arial.ttf';
//text Data
//$url = file_get_contents("http://whereis.the/file/40x40.txt");
$url = "PHP Freaks";

imagefttext($dest, 10, 0, 13, $height+30, $black, $font_file, $url);
// Output and free from memory
header('Content-Type: image/jpeg');
imagejpeg($dest);

imagedestroy($dest);
imagedestroy($src);

 

 

[attachment deleted by admin]

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.