gd

Finding spot on an image - mathematical way?

纵然是瞬间 提交于 2019-12-06 12:33:00
问题 I need to find a predefined area on an image and replace it with the other image (by just embedding the latter). The predefined spot would be a variable size rectangle area filled with solid background of the previously agreed colour. Any advise on how do I achieve this? I guess I can find a first pixel of the specified colour by doing a loop and going through the image row by row, pixel by pixel, but I feel like that's not the most efficient solution. Since the spot is supposed to be rather

JpGraph: How to control x/y offset, margins and color in v3.5.0b1 when using AccBarPlot?

那年仲夏 提交于 2019-12-06 11:32:22
A little background I am attempting to migrate a project built with Symfony 1.2 from one server to another. One of the functions of the project is to build a graph (originally done with JpGraph 2.3.5). The graph does not display as intended without modifications to the code and am looking for some insight on what I might be overlooking. Images are linked due to not having enough points to post. Graph Image Gallery The following graph is what is generated by the code block below <?php public function Graph($section) { $report = $section->getReport(); $this->crews = array(); foreach ($section-

PHP resize image proportionally to a bigger size

本秂侑毒 提交于 2019-12-06 11:31:09
I'm currently working on a script that shows thumbnails from a website on a mobile app, and I'm having problems with the "retina display". If the original image is big enough, I show a thumbnail with the double of the required size, and if it is not, I show it on the required size. Now, my function checks if it can be resized proportionally and if it can't, I resize it to the "min-width" or "min-height" and crop it from the center. Here is the problem: if it detects that the image can't be shown on the double of size, "scale up" the cropped size until it reaches the limits of the original size

Choosing between Imagemagick & GD for thumbnail creation

≯℡__Kan透↙ 提交于 2019-12-06 11:28:11
I'm going to write a function for thumbnail creation. I can use both Imagemagick & GD Library methods. Which method creates better thumbnails and is faster and better for server (load, ...)? Thanks $im = imagecreatefromjpeg('photo.jpg'); $ox = imagesx($im); $oy = imagesy($im); $nx = 320; $ny = 240; $nm = imagecreatetruecolor($nx, $ny); imagecopyresized($nm,$im,0,0,0,0,$nx,$ny,$ox,$oy); imagejpeg($nm, 't_photo.jpg'); VS exec('convert photo.jpg -resize 320x240 t_photo.jpg'); What do you think? Also every good thumbnail should be sharpened a bit... exec('convert photo.jpg -resize 320x240 -unsharp

Image processing and output using GD in php

懵懂的女人 提交于 2019-12-06 09:31:33
I want to control the display of images with the PHP GD library -- I am going to add some text to the bottom corner of it on the fly when a browser requests the image, rather than saving the text into the image. I know that I can do this: set the MIME type in the header and then call imagepng(...) with the filename to just display the image to the browser, but how would I embed it in a document? Like, <img src='somefile.php?i=1' ... /> do I just call imagepng with the filename but without setting the headers? Also, if someone copies the image source out of the source code and navigates to it

imagettftext function using font from remote server

左心房为你撑大大i 提交于 2019-12-06 08:47:12
问题 I am creating an image form font size, font family, font color in php. Everything was working fine until I got a new requirement. I was using ttf files and passing the path of particular ttf file in imagettftext function as a parameter. Now I am using google fonts and I am not getting an idea how to get the font in my function. I tried using couple of things such as passing 1.http://fonts.googleapis.com/css?family=Tangerine<br/> 2.http://themes.googleusercontent.com/static/fonts/abel/v3

PHP sharpness convolution martix

血红的双手。 提交于 2019-12-06 08:06:26
问题 I'm using a convolution matrix for sharpness in PHP GD and I want to change the sharpness "level" . Where would I make changes to this if I want to make it more or less sharp ? $image = imagecreatefromjpeg('pic.jpg'); $matrix = array( array(0, -1, 0), array(-1, 5, -1), array(0, -1, 0) ); imageconvolution($image, $matrix, 1, 0.001); header("Content-type: image/jpeg"); imagejpeg($image); 回答1: try looking on http://www.gamedev.net/reference/programming/features/imageproc/page2.asp There are lots

PHP Image quality issue on rotating and merging

北城余情 提交于 2019-12-06 08:04:06
问题 When i merge two images as one background and the other as target image. I m using pngs. When I rotate the target image and then merge, yes everything is fine except that the edges of rotated image becomes zigzag i means not smooth. How to make the edges smooth using php GD??? The code I am using: <?php // Create image instances $dest = imagecreatefrompng('bg.png'); $src = imagecreatefrompng('text.png'); $width = imagesx($src); $height = imagesy($src); imageantialias($src, true); $color =

PHP-GD imagejpeg unable to open

醉酒当歌 提交于 2019-12-06 08:00:22
When trying to save a thumbnail made with GD imagejpeg($tnImage, "../../img/thumbs/".$maxWidth."x".$maxHeight."_".$filename); I am getting the following error: Warning : imagejpeg() [function.imagejpeg]: Unable to open '../../img/thumbs/80x80_55865-drops.jpg' for writing: No such file or directory in /home/user/workspace/stewart/server-side/libImg.php /home/user/workspace/img/thumbs has its permissions set to 0x777. What can be wrong here? Where are you running the file from? If it's from the server-side directory then I think you're missing a "../" Try this: var_dump(realpath("../../img

Blend transparent gradient with an image using php GD library

ぃ、小莉子 提交于 2019-12-06 07:56:39
I try to render gradient on top of an image it need to be from full color to transparent, here is my code. I get black image and if I put start more then 0 I got white gradient but no image. the output image is 338x100 px but the input image need to be aligned to right if the image is narrower. function hex2rgb($hex) { $rgb[0] = hexdec(substr($hex, 0, 2)); $rgb[1] = hexdec(substr($hex, 2, 2)); $rgb[2] = hexdec(substr($hex, 4, 2)); return $rgb; } function int2rgb($color) { $result[] = ($color >> 16) & 0xFF; $result[] = ($color >> 8) & 0xFF; $result[] = $color & 0xFF; return $result; } if (isset