gd

Outputting image with underlined text using php GD library

天大地大妈咪最大 提交于 2019-12-01 06:09:17
问题 What is the best way to display underlined text and output the result as image with GD or any other library? 回答1: You can try using the Unicode underline combining character U+0332 . <?php // Set the content-type header('Content-type: image/png'); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // The text to draw $text =

Colorizing and swapping colors with PHP GD Image Library?

纵饮孤独 提交于 2019-12-01 05:15:23
问题 Hello I am in the process of trying to colorize and swap colors on an image using GD image library with PHP. I am using an original image located here: http://korlon.com/youknowbetter/test.jpg And wish to get it to a point where it is orange face with black clothes and hair much like you see here: http://youknowdifferent.org/ So far I've used the following code: <?php header('Content-type: image/jpeg'); $im = imagecreatefromjpeg('test.jpg'); imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter

How to check a PNG for grayscale/alpha color type?

此生再无相见时 提交于 2019-12-01 04:29:10
PHP and GD seem to have trouble creating images from PNGs of type greyscale with alpha when using imagecreatefrompng() . The results are incredibly distorted. I was wondering if anyone knew of a way to test for the colour type in order to notify the user of the incompatibility? Example: Original Image: http://dl.dropbox.com/u/246391/Robin.png Resulting Image: http://dl.dropbox.com/u/246391/Robin_result.png Code: <?php $resource = imagecreatefrompng('./Robin.png'); header('Content-type: image/png'); imagepng($resource); imagedestroy($resource); Cheers, Aron David Jones The colour type of a PNG

move_uploaded_file doesn't work, no error

ぃ、小莉子 提交于 2019-12-01 04:25:46
I am running running a script which moves an uploaded file with move_uploaded_file() . I have done this thousands of times but for some reason it's not working. I have confimred the following: <form> using method="post" and correct enctype correct file referenced from form directory has permissions 777 all the memory_limit , max_execution_time , etc are set to super high settings to avoid timeouts Basically, the script below returns with just Your image is too big. . I have also enabled ALL errors to display and still don't get an error. Any ideas? $time = time(); $target_path = "/absolute

PHP imagettftext partially bold

喜欢而已 提交于 2019-12-01 04:20:34
问题 I'm training my PHP skills to generate images. I need only one thing which doesn't work. I don't think it's possible on the way I want, but there should be another way. The code I already have is this: <?php $textSize = 10; $text = addslashes("Wietse: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada aliquet dolor, vitae tristique lectus imperdiet nec. Pellentesque et."); $maxWidth = 448; //Create image $im = imagecreate(468, 60); // Black background and White text $bg =

PHP GD how to draw text over a line

寵の児 提交于 2019-12-01 04:20:31
The final output should be like image(HELLO WORLD): Here is what i am doing:- $im = imagecreate(400,400); $txtcol = imagecolorallocate($im, 0xFF, 0x00, 0x00); $size = 20; $txt = 'DUMMY TEXT'; $font = './font/Capriola-Regular.ttf'; /*two points for base line*/ $x1 = 50; $x2 = 300; $y1 = 150; $y2 = 170; /*bof finding line angle*/ $delta_x = $x2-$x1; $delta_y = $y2-$y1; $texangle = (rad2deg(atan2($delta_y,$delta_x)) * 180 / M_PI)-360; /*eof finding the line angle*/ imageline($im,$x1,$y1,$x2,$y2,$txtcol); //Drawing line imagettftext($im, $size, $texangle, $x1, $y1, $txtcol, $font, $txt); //

Making an Image Greyscale with GD Library

心不动则不痛 提交于 2019-12-01 04:20:02
问题 My mission is to create a little app where you can upload a picture, and the app will turn it into ASCII art. I'm sure these exist already but I want to prove that I can do it myself. This would involve taking an image, making it greyscale and then matching each pixel with a character depending on how dark the picture is and how full the character is. So my question is, Using the GD Library (or i guess some other means if necessary) how do I make an image black and white? 回答1: A common

imagecrop() alternative for PHP < 5.5

有些话、适合烂在心里 提交于 2019-12-01 04:04:47
A simple question motivated by a curiosity, with probably a complex answer: Is it possible to emulate the new PHP 5.5 imagecrop() in earlier versions, like 5.4, by combining other GD functions? Awn.. But without the imagecrop() black line bug , please. :p This should be a drop-in replacement for imagecrop() (without the bug...): function mycrop($src, array $rect) { $dest = imagecreatetruecolor($rect['width'], $rect['height']); imagecopy( $dest, $src, 0, 0, $rect['x'], $rect['y'], $rect['width'], $rect['height'] ); return $dest; } Usage: $img = mycrop($img, ['x' => 10, 'y' => 10, 'width' => 100

How does “imagettfbbox()” in PHP work?

岁酱吖の 提交于 2019-12-01 03:26:42
Could you please explain what exactly the return value of imagettfbbox() mean? The manual says : imagettfbbox() returns an array with 8 elements representing four points making the bounding box of the text on success and FALSE on error. [...Table of points here...] The points are relative to the text regardless of the angle, so "upper left" means in the top left-hand corner seeing the text horizontally. But, I found it not very clear. For example, the return value: array(-1, 1, 61, 1, 61, -96, -1, -96) means the following points: (-1, -96) ------ (61, -96) | | | | | | | | | | | | (-1, 1) -----

imagecrop() alternative for PHP < 5.5

回眸只為那壹抹淺笑 提交于 2019-12-01 01:48:53
问题 A simple question motivated by a curiosity, with probably a complex answer: Is it possible to emulate the new PHP 5.5 imagecrop() in earlier versions, like 5.4, by combining other GD functions? Awn.. But without the imagecrop() black line bug, please. :p 回答1: This should be a drop-in replacement for imagecrop() (without the bug...): function mycrop($src, array $rect) { $dest = imagecreatetruecolor($rect['width'], $rect['height']); imagecopy( $dest, $src, 0, 0, $rect['x'], $rect['y'], $rect[