gd

Perspective transformation with GD

我是研究僧i 提交于 2019-12-12 08:48:54
问题 How can I apply a perspective transformation on an image using only the PHP GD library? I don't want to use a function someone else made I want to UNDERSTAND what's going on 回答1: I honestly don't know how to describe mathematically a perspective distortion. You could try searching the literature for that (e.g. Google Scholar). See also in the OpenGL documentation, glFrustum. EDIT : Interestingly, starting with version 8, Mathematica has a ImagePerspectiveTransformation. In the relevant part,

Give border to image created in PHP

耗尽温柔 提交于 2019-12-12 08:48:24
问题 How do I give a border to an image created using PHP? 回答1: function drawBorder(&$img, &$color, $thickness = 1) { $x1 = 0; $y1 = 0; $x2 = ImageSX($img) - 1; $y2 = ImageSY($img) - 1; for($i = 0; $i < $thickness; $i++) { ImageRectangle($img, $x1++, $y1++, $x2--, $y2--, $color); } } Then the usage would just to do. $color = imagecolorallocate($img, 255, 0, 0); drawBorder($img,$color, 255); 回答2: I didn't test this but I think it will do the trick. function addBorder($image, $width, $height) { $gd

Looking for GD tutorial in C/C++ [closed]

大兔子大兔子 提交于 2019-12-12 08:40:34
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I see a lot of GD tutorials for PHP, even though GD was written in C, not PHP. Could you please suggest any good tutorial for GD in C? 回答1: A bit of googling turned up nothing for me either - this is one of those things, for now anyway, that you must study the API reference and make up your own toy test programs

Determine if an image file is a photo or a graphic?

牧云@^-^@ 提交于 2019-12-12 08:04:23
问题 I'm embarking on what I believe may be somewhat of an experiment... To come up with (or discover, as it could already exist) a method to determine whether a given image file, regardless of format, is a photo or a graphic. "Photo" meaning something like scenery, people, etc. V.S. "Graphic" meaning an icon, illustration, chart, UI screenshot, etc. I came up with a nice PHP / ImageMagick script in the past week which pulls statistics from image files and nicely applies fixes to white balance,

PHP resize and watermarking images on the fly or create multiple versions?

若如初见. 提交于 2019-12-12 06:47:18
问题 I have a collection of 500+ images which have been re-sized to a maximum of 800px x 533px with a need to display thumbnails of these in a variety of sizes depending on the number in a particular category, so a section width of say 650px is filled in either 2/3/4 columns of photos. These images will are planned to bed used on a number of different domains each with a seperate watermark. Therefore i wrote a script which re-sizes images based on certain parameters (width / height / aspect) and

Add watermark to image (Base64) and convert it

佐手、 提交于 2019-12-12 04:59:35
问题 I have this PHP script (below): I getting base64 string using POST, than use imagecreatefromstring function and then trying to add watermark and save it. But the file is empty on the server after upload. What i'm doing wrong? <?php if($_SERVER['REQUEST_METHOD'] == "POST") { define('UPLOAD_DIR', 'img/'); $base64 = base64_decode(preg_replace('#^data:image/[^;]+;base64,#', '', $_POST['string'])); $stamp = imagecreatefrompng('img/wm.png'); $im = imagecreatefromstring($base64); $marge_right = 10;

PHP GD: Multiply image colors with tint color

ε祈祈猫儿з 提交于 2019-12-12 04:46:13
问题 can I use GD to multiply given color (RGB) with every pixel of an image resource (RGBA)? For example, if the given tint color is red (255, 0, 0), a black pixel on the image resource should stay black (since 255 * 0 = 0) and brighter pixels should be affected more by that red tint factor. I tried imagefilter($sprite, IMG_FILTER_COLORIZE, 255, 0, 0); but that only changes black pixels. NEGATE, IMG_FILTER_COLORIZE, NEGATE also won't work. 回答1: This seems to work for me: <?php // function for

How to get autocrops offset and size?

对着背影说爱祢 提交于 2019-12-12 03:52:29
问题 The php-function imagecropauto() can automaticly crop an image. and I guess its do some calculations and send the offset and size as paramters to the imagecrop() function. The size value I can get from the returned image, but is there someway to get the offset value? 回答1: Here is an ugly solution, by swaping the color of the botom-right corner. Is there a easier way? function autocrop_range($image) { $org_size = array(imagesx($image), imagesy($image)); $croped = imagecropauto($image, IMG_CROP

Problems rotating and resizing large images

ぐ巨炮叔叔 提交于 2019-12-12 03:36:46
问题 After a user has uploaded an image I'm trying to create a thumbnail of it. The problem is that when my script attempts to load a large image into memory in order to resample it (for example taken on an iPad at 2448px x 3264px), it runs out of memory when calling imagecreatefromjpeg . I can't increase the available memory because it's a shared server, and I can't install any alternative image libraries for the same reason. $name = "upload/1/" . $filename; move_uploaded_file($_FILES['myFile'][

counterpart to PIL's Image.paste in PHP

回眸只為那壹抹淺笑 提交于 2019-12-12 03:19:32
问题 I was asked to port a Python application to PHP (and I'm not very fond of PHP). The part I'm having trouble to port uses a set of monochromatic "template" images based on the wonderful Map Icons Collection by Nicolas Mollet. These template images are used to create an icon with custom background and foreground colors. PIL's Image.paste is used to "paste" the icon foreground with the selected color using the template Image as alpha mask. For example: How can I replicate this in PHP? Is there