Jump to content

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]

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.