gd

CSS: Set font to a size so the text would occupy whole container [duplicate]

旧城冷巷雨未停 提交于 2019-12-05 23:15:20
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: resize font to fit in a div (on one line) For a small flashcard maker app I need to set the correct font size so text would fill all the available width of a fixed-size container; like the text in the four boxes in this picture: A solution using PHP GD has been provided to this question. Is there a client side solution with css or javascript to this problem? 回答1: it's not brute force ;) HTML: <span id="txt"

Two unusual PHP operators used together to get image pixel color, please explain

江枫思渺然 提交于 2019-12-05 22:14:10
The PHP imagecolorat() function can be used to get the RGB values of an image pixel, as demonstrated in the documentation: $im = imagecreatefrompng("php.png"); $rgb = imagecolorat($im, 10, 15); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; I don't understand the last three lines at all; I know that they return the correct values, but I cannot figure out how the >> and & operators work together to do so. Could someone please explain? For reference, when $rgb = 9750526 , the RGB values turn out to be (148,199,254) . Thanks for any responses. & and >> are two different

PHP - Mask polygon over image

馋奶兔 提交于 2019-12-05 18:53:32
Hi Everyone (this is my first post), I am trying to figure a way of cropping a polygon out of an image. I have been reading other similar code. It seems that most code is based around the following process: Resize the image to fit the width and height of the polygon shape, Create a blank image of an unusual colour the same size, Overlay transparent pixels in the shape of the polygon, Overlay that on to the resized image Set the unusual colour to be transparent... My problem is I do not want the code to be reliant on the unusual colour not being in the original image. Does anyone have a better

GD imagejpeg() compression?

こ雲淡風輕ζ 提交于 2019-12-05 18:53:32
I'm working on a project where I edit the pixels of a jpg in PHP using the GD library. Its very crucial and key to my project that the output from PHP retains the pixel values I set (cough-steganography-cough). This is the first time I've attempted image manipulation in PHP. I've had no problems before in my Java implementations, so I was foolish not to investigate GD's jpeg compression quality before pursuing further. It turns out that after all my effort, my code does not function the way its supposed to. I am pretty sure it is not my code (tested the encode and decode functions on edited

Drawing on image with the GD library in PHP

ε祈祈猫儿з 提交于 2019-12-05 18:34:33
I have created a code to generate a random pattern image. it creates an image with given width and height and fills it with small 40x40 pixel rectangles. this is my code: <?php $width = 1000; $height = 600; $image_p = imagecreate($width, $height); $baseR = 255 - rand(0, 100); $baseG = 255 - rand(0, 100); $baseB = 255 - rand(0, 100); for ($i = 0; $i <= floor($width / 40); $i++){ for ($j = 0; $j <= floor($height / 40); $j++){ $val = floor(100 * (rand(0, 100) / 100)); $r = $baseR - $val; $g = $baseG - $val; $b = $baseB - $val; $color = imagecolorallocate($image_p, $r, $g, $b);

How to avoid black background when rotating an image 45 degree using PHP?

我是研究僧i 提交于 2019-12-05 18:04:44
Hi I have to flip a thumpnail image before merge it with another jpeg file. but when I rotate 45 degree using php. It shows a black background. how can I avoid that. any body can help me. <? $image = "130.jpg"; $degrees = 25; for($i=0;$i<count($data);$i++){ $ext = ""; $extarr = ""; $extarr = explode(".", $data[$i]['name']); $ext = array_pop($extarr); if($ext == "png"){ $rotate = imagecreatefrompng("images/".$data[$i]['name']); $transColor = imagecolorallocatealpha($rotate, 255, 255, 255, 270); $watermark1[$i] = imagerotate($rotate, ((360-$degrees)%360), $transColor); } } function

Pass GD image object to Imagick?

霸气de小男生 提交于 2019-12-05 17:50:20
I'm generating a barcode with PEAR::Image_Barcode which uses GD, but I need to write that barcode onto a section of a PDF and PHP/Imagick seems to be the easiest way to do that, is there any way to convert a GD image object into something Imagick can work with? here we go: ob_start(); Image_Barcode::draw($barcode, 'upca', 'gif'); $couponBarcode = ob_get_contents(); ob_end_clean(); $second = new Imagick(); $second->readImageBlob($couponBarcode) it's writing the image to an output buffer with GD then reading that variable into an Imagick object ImageMagick has internal image creation functions.

PHP update kerning problem with imagettftext() and imagefttext() functions

一笑奈何 提交于 2019-12-05 15:53:06
Our dev server was recently upgraded to PHP v5.2.13. With that upgrade we have found that our png images are having kerning (letter spacing) problems. We've tried numerous fonts and haven't found a solution yet. We are creating images using the GD library and writing text to the images using font files and the imagettftext() or imagefttext() functions. Has anyone else run into this? Am I misunderstanding something or should this be submitted to PHP as a bug? Are there any cool workarounds I haven't thought of yet? Here's an example of the new and old tahoma bold. Other fonts (bold and non-bold

sIFR or FLIR?

流过昼夜 提交于 2019-12-05 15:35:04
I've recently bumped into facelift, an alternative to sIFR and I was wondering if those who have experience with both sIFR and FLIR could shed some light on their experience with FLIR. For those of you who've not yet read about how FLIR does it, FLIR works by taking the text from targeted elements using JavaScript to then make calls to a PHP app that uses PHP's GD to render and return transparent PNG images that get placed as background for the said element, where the overflow is then set to hidden and padding is applied equal to the elements dimensions to effectively push the text out of view

Way to find an image inside another image in PHP/GD?

Deadly 提交于 2019-12-05 13:36:41
I need a way to find the location of an image inside another image in PHP/gd. For example, locate this image: inside this image: I tried to make a function myself to do this, and I WAS successful, but it's very slow, it takes over 50 seconds at 100% CPU for me with the example pictures above, and I'm not sure how to optimize it (if possible) further. So is there some way to do this faster? Preferably, much faster? (For instance Auto Hotkey can do the same operation in <2 seconds on the same computer with this function https://autohotkey.com/docs/commands/ImageSearch.htm ) Edit: I figured I