gd

How to generate image file using this PHP function?

丶灬走出姿态 提交于 2019-12-24 19:26:13
问题 I've been looking for a GD based solution for adding a perspective transformation to an image and eventually found something that seems promising: http://www.jqueryit.com/2010/03/set-perspective-of-image-using-php-gd.html However, I'm not sure how to actually generate a new image using this function. My approach was this: function perspective($i,$gradient=0.85,$rightdown=true,$background=0xFFFFFF) { $mult=5; $w=imagesx($i); $h=imagesy($i); $image=imagecreatetruecolor($w*$mult,$h*$mult);

Resizing/Cropping Image to adjust into layout

馋奶兔 提交于 2019-12-24 13:17:07
问题 I'm having issue with the re-sizing / scaling the thumbnails in to the desired layout. I am able to generate the thumbnails here's the code to crop/resize. $filename = $key.$_FILES["files"]["name"][$key]; $filetmp = $_FILES["files"]["tmp_name"][$key]; $filetype = $_FILES["files"]["type"][$key]; $filesize = $_FILES["files"]["size"][$key]; $fileinfo = getimagesize($tmp_name); $filewidth = $fileinfo[0]; $fileheight = $fileinfo[1]; // GETS FILE EXTENSION $fileextension = pathinfo($filename,

Splitting APNG into png images with PHP

倖福魔咒の 提交于 2019-12-24 11:55:25
问题 I have a php code that splits an animated PNG image (APNG) into frames, but there is some kind of error. The images that are created by the function are not valid (PHP does not return an image resource in PHP imagecreatefrompng() function (neither it's displayed in Firefox browser). Quoting the function from How can I split animated PNG with PHP? by James Holderness function splitapng($data) { $parts = array(); // Save the PNG signature $signature = substr($data, 0, 8); $offset = 8; $size =

Auto New Line In GD Library

不羁的心 提交于 2019-12-24 08:35:48
问题 I'm using the GD Library to create images from data I'm pulling from an API. The strings that are returned can sometimes be kind of lengthy, and I'm hoping to find a way to automatically create a new line for text if the string goes too far. Is there something like this built into the GD library, or will I have to write some code to count the characters and move everything to a new line if it goes too long? 回答1: GD is strictly for drawing. You'll need a text layout engine such as Pango. 回答2:

Missing chars in JpGraph

安稳与你 提交于 2019-12-24 07:42:14
问题 I have a web site that runs on Windows and uses cp1252 (aka Win-1252 ) so it can display Spanish characters. The app generates some plots with JpGraph 2.3 . These plots use the Tahoma Open Type font family to display text labels. Strings are provided in ANSI (i.e., cp1252) and font files support cp1252 (actually, the *.ttf files were copied from the system's font folder). It's been working fine in several setups from PHP/5.2.6 to PHP/5.3.0. Problems started when I ran the app under PHP/5.3.1

How to prevent having the “is not a valid image file” error when using GD function imagecreatefrom* in php?

心不动则不痛 提交于 2019-12-24 05:09:05
问题 I am using imagecreatefromgif / imagecreatefromjpeg / imagecreatefromjpeg functions with uploaded images and sometimes get an error (e.g. Warning: imagecreatefromgif(): ... is not a valid GIF file) when the image is corrupted. I read lots of posts about this topic and couldn't find a "working" answer. I did try some of the following to validate the image (as suggested on other posts) but none of them worked in ALL situations. If the image does not have the header info, the following works,

Problem using font with imagettftext

拜拜、爱过 提交于 2019-12-24 04:44:09
问题 this is the error message i get when I change the environment of an effective website: Warning: imagettftext() [function.imagettftext]: Could not find/open font First I was thinking it cames from a lack of rights on the files, but it doesn't, I check the path and set all the files in 777... Then I check GD, and it looks like it is installed : GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.3.5 GIF Read

PHP imagettftext return bounding box differs from rendered bounding box

半城伤御伤魂 提交于 2019-12-24 03:16:34
问题 I'm using imagettftext to render a PNG file. A call to imagettftext() returns the bounding box that the text was rendered in, but on closer inspection, the text is being rendered slightly outside of it's own bounding box! The bounding box is correct (I inspected the pixel coords of the image), but the text location is incorrect, it outputs this, where the box is the returned bounding box after rendering the text: My code is: // helper function for geting textbox bounds function bounds($text,

PHP Function to bend/warp an image

两盒软妹~` 提交于 2019-12-23 22:40:35
问题 I'm working with my simple PHP captcha algorithm (http://www.source.ofitall.com/devel/captcha.php) and I have been struggling to try and adjust it to be the more attractive and easier to read, Google style captcha. Does anyone know of a function that will take in a GD image reference and bend/warp it, Google style? 回答1: If you can use ImageMagick on your server you might want to give this a try: convert koala.gif -background Blue -wave 10x64 wave.jpg UPDATE : If you aren't using some library

Need to center a resized thumbnail

十年热恋 提交于 2019-12-23 17:24:48
问题 I have the following code for generating thumbnails from a user upload. It makes the thumbnail, keeps aspect ratio and adds a white background. But it aligns it to the top left. I need to center it, both horizontally and vertically. function makethumbnail($thumbw,$thumbh,$thumbName,$sourceName){ $ext=getExtension($sourceName); //echo $ext; $sourcePath = 'images/logos/deals/'; // Path of original image $sourceUrl = 'http://www.malldeals.com/admin/convert/'; $thumbPath = $sourcePath; //