gd

PHP - imagettftext not working and GD installed

…衆ロ難τιáo~ 提交于 2019-12-05 04:50:30
It's being long hours that I'm still looking for answer to this problem.. All the solutions I find are around catching the font name but I am pretty sure this isn't my problem. It looks like GD is installed array(11) { ["GD Version"]=> string(27) "bundled (**2.0.34 compatible**)" ["FreeType Support"]=> bool(false) ["T1Lib Support"]=> bool(false) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPEG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(true) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"

Write text on the image in proportion

。_饼干妹妹 提交于 2019-12-05 02:28:24
So I have the image: and I want to add text under the image (make demotivational image). So I extend it height and add additional height to the bottom. What I need is write the text: Top text bottom longer text also I need these words to be centered on the image. So the ouput should be: everything is on PHP GD library. The problem is - I don't know how to calculate proportion of font size and center it. My function which is not working, calculate font size wrong and align text wrong.. private function __generate_text_pref($type) { $data = array(); switch ($type) { case 'title': $data['percent'

Resize PNG image in PHP

女生的网名这么多〃 提交于 2019-12-05 01:44:55
I'm getting a no image display when resizing PNG however the following code works for JPEG. 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; } // Resample $image_p = imagecreatetruecolor($width, $height); if( $type )){ switch( $type ){ case 'image/jpeg': $image = imagecreatefromjpeg($fileName); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); imagejpeg($image_p, null, 100); break; case 'image

Combine two images (.JPG) using PHP GD

穿精又带淫゛_ 提交于 2019-12-05 01:24:16
问题 I can't find a solution to this. I want to add 20px empty space to this image: http://img233.imageshack.us/img233/419/78317401.jpg and then paste this watermark at the bottom (on the blank space) So the output would be: http://img252.imageshack.us/img252/4554/wynik.jpg I don't want to stretch it. EDIT Did it with WIdeImage. Rly simple. 回答1: Try wide image api http://wideimage.sourceforge.net/ Check out one of their this demo may be that help you Merge and Resize 回答2: 1) Load both images with

Amazon EC2 - PHP GD image library

杀马特。学长 韩版系。学妹 提交于 2019-12-05 00:48:28
I've got a brand new install of WordPress setup and activated a custom-built theme along with a good amount of plugins. In the posts, I have built it so the user can create a post, upload an image as a thumbnail and it will automatically resize the image to a custom size set in my functions.php file. All this has been working on my local end (MAMP) correctly but when I tried making everything work on our Amazon EC2 server, the images do not resize to the size set. They resize by actual code but do not resize the actual image and save it in the new size. Apologies if the question/subject is

Center aligning multiple lines of text with GD and PHP

只谈情不闲聊 提交于 2019-12-05 00:17:12
问题 I'm trying to print multiple lines of text on an image and center align them. i.e. This is A string of text Right now, I only have the left position for the whole string. Any shortcuts on getting that to work? I think it might have to be a getttfbox on the whole string, then an explode on the line breaks, then center the new text inside that larger ttfbox. That's a pain in the ass... EDIT: Came up with a solution: foreach ( $strings as $index => $string ) { $parts = explode ( "\n", $string[

Why rand() isn't really random?

扶醉桌前 提交于 2019-12-04 22:35:09
问题 I wanted to put random points on an image (stars in space for some little fun side project) I have this simple script. <?php $gd = imagecreatetruecolor(1000, 1000); $white = imagecolorallocate($gd, 255, 255, 255); for ($i = 0; $i < 100000; $i++) { $x = rand(1,1000); $y = rand(1,1000); imagesetpixel($gd, round($x),round($y), $white); } header('Content-Type: image/png'); imagepng($gd); ?> Keep in mind this is just for testing, that is why I put 100000 in for loop so it shows the pattern I

PHP Isometric cube with GD

自闭症网瘾萝莉.ら 提交于 2019-12-04 22:10:56
I need to create something like this with PHP and GD: The three visible faces will be three parts of the same image, of which I know the coordinates. I suppose that this can be done with image transformations and some maths. The rotation of the cube will be always the same. I don't need "stroke" edges and face lighting like in that picture, I just need a "shadeless" cube. Finally, the result should be an alpha-transparent PNG. P.S. I only have GD on my host, I don't have access to ImageMagick. you are searching for something like this? <?php $size=100; $first_poligon = array( 0, $size/4, //

kohana 3 uploading image without using any modules?

风格不统一 提交于 2019-12-04 20:38:53
does anybody have an example of uploading images in kohana 3 without using any modules eventually ? i used https://github.com/kohana/image/tree/3.1%2Fmaster but my error is: Fatal error: Uncaught Kohana_Exception [ 0 ]: Installed GD does not support images is there any easy and fast way to upload files in a kohana 3 based website? thanks! Kohana API should help. Basic steps are: Create Validation object ( $array = Validation::factory($_FILES); ) Define rules ( $array->rule('file', 'Upload::not_empty')->rule('file', 'Upload::type', array(array('jpg', 'png', 'gif'))); ) Check file(s) ( if (

How to Improve my php image resizer to support alpha png and transparent GIFs

人盡茶涼 提交于 2019-12-04 20:33:33
I use this function to resize images but i end up with ugly creepy image with a black background if it's a transparent GIF or PNG with alpha, however it works perfectly for jpg and normal png. function cropImage($nw, $nh, $source, $stype, $dest) { $size = getimagesize($source); $w = $size[0]; $h = $size[1]; switch($stype) { case 'gif': $simg = imagecreatefromgif($source); break; case 'jpg': $simg = imagecreatefromjpeg($source); break; case 'png': $simg = imagecreatefrompng($source); break; } $dimg = imagecreatetruecolor($nw, $nh); switch ($stype) { case "png": imagealphablending( $dimg, false