Search Results

Search found 356 results on 15 pages for 'gd'.

Page 5/15 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Get remote image using cURL then resample.

    - by Chris
    I want to be able to retrieve a remote image from a webserver, resample it, and then serve it up to the browser AND save it to a file. Here is what I have so far: $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "$rURL"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser $out = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); $imgRes = imagecreatefromstring($out); imagejpeg($imgRes, $filename, 70); header("Content-Type: image/jpg"); header("Content-length: ".filesize($filename)); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); readfile("$filename"); exit(); Update Updated code to include imjpeg step to save the image as lower quality. But how do I then, efficiently, serve this up to the browser. I currently, later in the code, do this readfile("$filename"); along with some header information but that means I'm reading the file back in again which seems inefficient.

    Read the article

  • How do you make npiet use macports' libgd?

    - by Adrian
    I am trying to install npiet (http://www.bertnase.de/npiet/). It requires libgd and libpng. I have installed both of these with macports, but when I run the configure script included with npiet, it says that it can't find them. It also doesn't recognize --with-png=/opt/local/bin.

    Read the article

  • Cannot modify header information - headers already sent by

    - by bhaskaragr29
    <?php //require_once 'wordwrap.php'; //$text="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"; $im=imagecreatefrompng('testing.png'); //$arr=word($text); $white = imagecolorallocate($im,255,255,255); $font='arial.ttf'; $m=121; for($i=0;$i<sizeof($arr);$i++) { imagettftext($im,25,11,124,'Hello world!', $white); } header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> I am getting error..please help me on this.

    Read the article

  • Cannot modify header information - headers already sent by

    - by bhaskaragr29
    header('Content-type: image/png'); require_once 'wordwrap.php'; $text="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"; $im=imagecreatefrompng('testing.png'); $arr=word($text); $white = imagecolorallocate($im,255,255,255); $grey = imagecolorallocate($im, 128, 128, 128); $font='arial.ttf'; $m=121; for($i=0;$i Word function is returning an array.I am writing array on image as multiple lines.I am getting error when when placed below imagepng function Warning: Cannot modify header information - headers already sent by (output started at /home2/puneetbh/public_html/prideapp/Testing/wordwrap.php:33) in /home2/puneetbh/public_html/prideapp/Testing/checkimage.php on line 12 ‰PNG ??? IHDR?? ??ô???J"Þ/?? ?IDATxœì¼KvÉŽ%ŠŸ}Ü)EfäjÕxÝËÇ›nE^)Èãn??Õ€J‘UÕ~ß --ŠKäƒÛàÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ7nܸqãÆ When placd in starting i m getting this file cannot be displayed because it contains errors. PLease Help

    Read the article

  • How to generate semi transparent shapes in php using gdlib

    - by fabbrillo
    Hi, this is the script i made // Create image $img = imagecreatetruecolor($w, $h); // Transparent image $white = imagecolorallocate($img,255,255,255); imagefilledrectangle($img,0,0,$w,$h,$white); imagecolortransparent($img, $white); //imagealphablending( $img, true ); //imagesavealpha( $img, true ); // Shape color $bgColor = imagecolorallocatealpha($img, 100, 250, 250, 70); imagefilledrectangle($img, 15, 20, 50, 100, $bgColor); imagefilledrectangle($img, 10, 25, 60, 100, $bgColor); imagepng($img, 'file.png'); the problem is the rectangles are transparent among them but not with the background i mean, i need to create a transparent image with a semi transparent shape inside any suggestions? thanks for your help

    Read the article

  • Batch folder of images into grayscale using php

    - by James
    Can anyone spot where I'm going wrong here. It should be creating grayscale copies of images in one folder and saving them in another folder. Could it be to do with the way im referencing the file locations. Folder permissions on both folders are 777 function grayscalecopy($targetfile, $outputfile){ $size = GetImageSize($targetfile); $width = $size[1]; $height = $size[0]; $canvas = imagecreatetruecolor($width, $height); $sourceimage = imagecreatefromjpeg($targetfile); imagefilter($sourceimage, IMG_FILTER_GRAYSCALE); imagecopy($canvas, $sourceimage, 0, 0, 0, 0, $width, $height); imagejpeg($canvas, $outputfile, 95); imagedestroy($sourceimage); imagedestroy($canvas); echo "Converted ".$targetfile." to grayscale as ".$outputfile." ".$width."x".$height."<br/>"; } $serverfiles = glob("artworkimages/thumbs/*.*"); //$numbertocache = count($serverfiles); $numbertocache = 10; for ($i=0; $i<$numbertocache; $i++) { $serverfilesshort=explode("/",$serverfiles[$i]); $serverfilesshort=$serverfilesshort[count($serverfilesshort)-1]; grayscalecopy($serverfiles[$i], "artworkimages/thumbs/grays/".$serverfilesshort); }

    Read the article

  • Warning: Cannot modify header information - headers already sent by

    - by bhaskaragr29
    When i try run this file i am getting this error. <?php $im = imagecreatetruecolor(100, 100); // sets background to red $red = imagecolorallocate($im, 255, 0, 0); imagefill($im, 0, 0, $red); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> Warning: Cannot modify header information - headers already sent by (output started at C:\xampp1\htdocs\check\2.php:1) in C:\xampp1\htdocs\check\2.php on line 7 ?PNG ??? IHDR???n??????V,????PLTE????[an????fIDAT?c`?`fx???`?????41???????q?@?;{á0? ?i

    Read the article

  • Image resizing not working with png images

    - by user304828
    it not work with png created a thumb png but haven't data , like null data :D with jpg , jpeg still working without error why ? function thumbnail($pathtoFile,$thumWidth,$pathtoThumb) { //infor of image $infor = pathinfo($pathtoFile); // Setting the resize parameters list($width, $height) = getimagesize($pathtoFile); $modwidth = $thumWidth; $modheight = floor( $height * ( $modwidth / $width )); // Resizing the Image $thumb = imagecreatetruecolor($modwidth, $modheight); switch(strtolower($infor['extension'])) { case 'jpeg': case 'jpg': $image = imagecreatefromjpeg($pathtoFile); break; case 'gif': $image = imagecreatefromgif($pathtoFile); break; case 'png': $image = imagecreatefrompng($pathtoFile); break; } imagecopyresampled($thumb, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); switch(strtolower($infor['extension'])) { case 'jpeg': case 'jpg': imagejpeg($thumb,$pathtoThumb, 70); break; case 'gif': imagegif($thumb,$pathtoThumb, 70); break; case 'png': imagepng($thumb,$pathtoThumb, 70); break; } //destroy tmp imagedestroy($thumb); }

    Read the article

  • I'm working on a website that sells different artwork, what's the best way to handle different image

    - by ThinkingInBits
    I'm working on a website that will allow users to upload and sell their artwork in different sizes. I was wondering what the best way would be to handle the different file sizes automatically. A few points I was curious on: How to define different size categories (small, medium, large) in such a way that I'll be able to dynamically re-size images with proportional dimensions. Should I store actual jpegs of the different sizes for download? Or would it be easier to generate these different sizes for download on the fly My thumbnails will be somewhat larger than your average thumbnails, should I store a second 'thumbnail image' with the sites watermark overlaying it? Or once again, generate this on the fly? All opinions, advice are greatly appreciated!

    Read the article

  • add text to curved image

    - by miki123
    $config['source_image'] = '/path/to/image/mypic.jpg'; $config['wm_text'] = 'Copyright 2006 - John Doe'; $config['wm_type'] = 'text'; $config['wm_font_path'] = './system/fonts/texb.ttf'; $config['wm_font_size'] = '16'; $config['wm_font_color'] = 'ffffff'; $config['wm_vrt_alignment'] = 'bottom'; $config['wm_hor_alignment'] = 'center'; $config['wm_padding'] = '20'; $this->image_lib->initialize($config); $this->image_lib->watermark(); This is water mark code in php, it is working fine when we add text to curve image like mug image, the letter is not overlap the curved image how can we overcome?

    Read the article

  • PHP - Resize an image and fill gaps of proportions with a color

    - by Kerry
    I am uploading logos to my system, and they need to fix in a 60x60 pixel box. I have all the code to resize it proportionately, and that's not a problem. My 454x292px image becomes 60x38. The thing is, I need the picture to be 60x60, meaning I want to pad the top and bottom with white each (I can fill the rectangle with the color). The theory is I create a white rectangle, 60x60, then I copy the image and resize it to 60x38 and put it in my white rectangle, starting 11px from the top (which adds up to the 22px of total padding that I need. I would post my code but it's decently long, though I can if requested. Does anyone know how to do this or can you point me to code/tutorial that does this?

    Read the article

  • imageconvolution leaves black dot in the upper left corner

    - by Peter O.
    I'm trying to sharp resized images using this code: imageconvolution($imageResource, array( array( -1, -1, -1 ), array( -1, 16, -1 ), array( -1, -1, -1 ), ), 8, 0); When the transparent PNG image is sharpened, using code above, it appears with a black dot in the upper left corner (I have tried different convolution kernels, but the result is the same). After resizing the image looked OK. 1st image is the original one 2nd image is the sharpened one EDIT: What am I going wrong? I'm using the color retrieved from pixel. $color = imagecolorat($imageResource, 0, 0); imageconvolution($imageResource, array( array( -1, -1, -1 ), array( -1, 16, -1 ), array( -1, -1, -1 ), ), 8, 0); imagesetpixel($imageResource, 0, 0, $color); Is imagecolorat the right function? Or is the position correct? EDIT2: I have changed coordinates, but still no luck. I've check the transparency given by imagecolorat (according to this post). This is the dump: array(4) { red => 0 green => 0 blue => 0 alpha => 127 } Alpha 127 = 100% transparent. Those zeroes might cause the problem...

    Read the article

  • Good way to identify similar images?

    - by Nick
    I've developed a simple and fast algorithm in PHP to compare images for similarity. Its fast (~40 per second for 800x600 images) to hash and a unoptimised search algorithm can go through 3,000 images in 22 mins comparing each one against the others (3/sec). The basic overview is you get a image, rescale it to 8x8 and then convert those pixels for HSV. The Hue, Saturation and Value are then truncated to 4 bits and it becomes one big hex string. Comparing images basically walks along two strings, and then adds the differences it finds. If the total number is below 64 then its the same image. Different images are usually around 600 - 800. Below 20 and extremely similar. Are there any improvements upon this model I can use? I havent looked at how relevant the different components (hue, saturation and value) are to the comparison. Hue is probably quite important but the others? To speed up searches I could probably split the 4 bits from each part in half, and put the most significant bits first so if they fail the check then the lsb doesnt need to be checked at all. I dont know a efficient way to store bits like that yet still allow them to be searched and compared easily. I've been using a dataset of 3,000 photos (mostly unique) and there havent been any false positives. Its completely immune to resizes and fairly resistant to brightness and contrast changes.

    Read the article

  • String to image only produces black background

    - by Phil Jackson
    Hi im really having a problem find how to fix this. $string = "foo"; $font = 4; $width = ImageFontWidth($font) * strlen($string); $height = ImageFontHeight($font); $im = @imagecreatetruecolor ($width,$height); $bg = imagecolorallocate($im, 255, 255, 255); $textcolor = imagecolorallocate($im, 0, 0, 0); imagestring($im, 5, 0, 0, $string, $textcolor); imagegif($im, 'somefile.gif', 8); imagedestroy($im); I cannot seem to change the background from black. Does anyone have any ideas?

    Read the article

  • problem creating jpg thumb with php

    - by Ross
    Hi, I am having problems creating a thumbnail from an uploaded image, my problem is (i) the quality (ii) the crop http://welovethedesign.com.cluster.cwcs.co.uk/phpimages/large.jpg http://welovethedesign.com.cluster.cwcs.co.uk/phpimages/thumb.jpg If you look the quality is very poor and the crop is taken from the top and is not a resize of the original image although the dimesions mean it is in proportion. The original is 1600px wide by 1100px high. Any help would be appreciated. $thumb = $targetPath."Thumbs/".$fileName; $imgsize = getimagesize($targetFile); $image = imagecreatefromjpeg($targetFile); $width = 200; //New width of image $height = 138; //This maintains proportions $src_w = $imgsize[0]; $src_h = $imgsize[1]; $thumbWidth = 200; $thumbHeight = 138; // Intended dimension of thumb // Beyond this point is simply code. $sourceImage = imagecreatefromjpeg($targetFile); $sourceWidth = imagesx($sourceImage); $sourceHeight = imagesy($sourceImage); $targetImage = imagecreate($thumbWidth,$thumbHeight); imagecopyresized($targetImage,$sourceImage,0,0,0,0,$thumbWidth,$thumbWidth,imagesx($sourceImage),imagesy($sourceImage)); //imagejpeg($targetImage, "$thumbPath/$thumbName"); imagejpeg($targetImage, $thumb); chmod($thumb, 0755);

    Read the article

  • Which is more efficient/faster when calling a cached image?

    - by andufo
    Hi, i made an image resizer in php. When an image is resized, it caches a new jpg file with the new dimensions. Next time you call the exact img.php?file=hello.jpg&size=400 it checks if the new jpg has already been created. If it has NOT been created yet, it creates the file and then prints the output (cool). If it ALREADY exists, no new file needs to be generated and instead, it just calls the already cached file. My question is regarding the second scenario. Which of these is faster? redirecting: header('Location: cache/hello_400.jpg');die(); grabbing data and printing the cached file: $data = file_get_contents('cache/hello_400.jpg'); header('Content-type: '.$mime); header('Content-Length: '.strlen($data)); echo $data; Any other ways to improve this?

    Read the article

  • Codeigniter Image Library Cropping an Image with 2 sets of coordinates to make square anywhere?

    - by chris
    Spending time reading through the docs, and searching for examples. I understand cropping an image from top 0, and left 0 is pretty straight forward. However. I would like to pass 2 sets of coordinates, a starting point and an ending point. Four Points, a Square that is defined anywhere. However from the examples I am finding, and from what I gather the rendition is not going to let me do this. codeigniter so I am seeking confirmation on this thought, is it true that I can only provide end points from 0, and it crops a square based on said end points or can I actually specify an x start, an x end, and similar for y? Or is there some other technique I can use within codeigniter that will allow me to pass for coordinates for starting and ending points?

    Read the article

  • Fetch image from folder via datatable does not work after placing image in subdirectory

    - by Arnold Bishkoff
    I am having trouble wrapping my head around the following I have code that fetches an image via smarty in a line img src="getsnap.php?picid={$data[$smarty.section.sec.index].picno|default:$nextpic}&typ=pic&width={$config.disp_snap_width}&height={$config.disp_snap_height}" class="smallpic" alt="" / this works if i pull the image from /temp/userimages/userid/imageNo.ext but because an OS can segfault if you store too many folders or images in a directory i have code that assigns the user image to a subdirectory based upon division of a subdir per 1000 userids. so in thise case i have user id 94 whos images get stored in /siteroot/temp/userimages/000000/94/pic_1.jpg (through 10) or tn_1 (through 10).jpg here is the code for getsnap.php <?php ob_start(); if ( !defined( 'SMARTY_DIR' ) ) { include_once( 'init.php' ); } include('core/snaps_functions.php'); if (isset($_REQUEST['username']) && $_REQUEST['username'] != '') { $userid = $osDB-getOne('select id from ! where username = ?',array(USER_TABLE, $_REQUEST['username']) ); } else { // include ( 'sessioninc.php' ); if( !isset($_GET['id']) || (isset($_GET['id'])&& (int)$_GET['id'] <= 0 ) ) { $userid = $_SESSION['UserId']; } else { $userid = $_GET['id']; } } if (!isset($_GET['picid']) ) { if ((isset($_REQUEST['type']) && $_REQUEST['type'] != 'gallery') || !isset($_REQUEST['type']) ) { $defpic = $osDB-getOne('select picno from ! where userid = ? and ( album_id is null or album_id = ?) and default_pic = ? and active = ? ',array(USER_SNAP_TABLE, $userid,'0','Y','Y' ) ); if ($defpic != '') { $picid = $defpic; } else { $picid = $osDB-getOne('select picno from ! where userid = ? and ( album_id is null or album_id = ?) and active=? order by rand()',array(USER_SNAP_TABLE, $userid,'0','Y' ) ); } unset( $defpic); } } else { $picid = $_GET['picid']; } $typ = isset( $_GET['typ'])?$_GET['typ']:'pic' ; $cond = ''; if ( ($config['snaps_require_approval'] == 'Y' || $config['snaps_require_approval'] == '1') && $userid != $_SESSION['UserId'] ) { $cond = " and active = 'Y' "; } $sql = 'select * from ! where userid = ? and picno = ? '.$cond; //Get the pic $row =& $osDB-getRow ( $sql, array( USER_SNAP_TABLE, $userid, $picid ) ); //Okay pic was found in the DB, Lets actually do something // $id = $userid; $dir = str_pad(($id - ($id % 1000))/100000,6,'0',STR_PAD_LEFT); $zimg = USER_IMAGES_DIR.$dir; $img = getPicture($zimg, $userid, $picid, $typ, $row); //$img = getPicture($userid, $picid, $typ, $row); //$img = getPicture($dir, $userid, $picid, $typ, $row); $ext = ($typ = 'tn')?$row['tnext']:$row['picext']; // Now pic is built as // something pic_x.ext ie pic_2.jpg if ( $img != '' && ( ( hasRight('seepictureprofile') && ( $config['snaps_require_approval'] == 'Y' && $row['active'] == 'Y' ) ||$config['snaps_require_approval'] == 'N' ) || $userid == $_SESSION['UserId'] ) ) { $img2 = $img; //$img2 = $dir.'/'.$img; } else { $gender = $osDB-getOne( 'select gender from ! where id = ?', array( USER_TABLE, $userid ) ) ; if ($gender == 'M') { $nopic = SKIN_IMAGES_DIR.'male.jpg'; } elseif ($gender == 'F') { $nopic = SKIN_IMAGES_DIR.'female.jpg'; } elseif ($gender == 'D') { $nopic = SKIN_IMAGES_DIR.'director.jpg'; } $img2 = imagecreatefromjpeg($nopic); $ext = 'jpg'; } ob_end_clean(); header("Pragma: public"); header("Content-Type: image/".$ext); header("Content-Transfer-Encoding: binary"); header("Cache-Control: must-revalidate"); $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() - 30) . " GMT"; header($ExpStr); $id = $userid; $dir = str_pad(($id - ($id % 1000))/100000,6,'0',STR_PAD_LEFT); $zimg = USER_IMAGES_DIR.$dir; //header("Content-Disposition: attachment; filename=profile_".$userid."_".$typ.".".$ext); //header("Content-Disposition: attachment; filename=$dir.'/'.profile_".$userid."".$typ.".".$ext); //header("Content-Disposition: attachment; filename=profile"$dir".'/'.".$userid."_".$typ.".".$ext); header("Content-Disposition: attachment; filename=profile_".$userid."_".$typ.".".$ext); /* if ($_SESSION['browser'] != 'MSIE') { header("Content-Disposition: inline" ); } */ if ($ext == 'jpg') { imagejpeg($img2); } elseif ($ext == 'gif') { imagegif($img2); } elseif ($ext == 'png') { imagepng($img2); } elseif ($ext == 'bmp') { imagewbmp($img2); } imagedestroy($img2); ?

    Read the article

  • Dynamic status bar image creation in php

    - by jane
    I am new to image creation in php. Have a look here http://s.kapipal.com/image_progress?v=.46 If you change the param value, bar progress should also be changed to passed value How can i implement something like above? Thanks for the help inadvance

    Read the article

  • How do I add text to curved image?

    - by miki123
    $config['source_image'] = '/path/to/image/mypic.jpg'; $config['wm_text'] = 'Copyright 2006 - John Doe'; $config['wm_type'] = 'text'; $config['wm_font_path'] = './system/fonts/texb.ttf'; $config['wm_font_size'] = '16'; $config['wm_font_color'] = 'ffffff'; $config['wm_vrt_alignment'] = 'bottom'; $config['wm_hor_alignment'] = 'center'; $config['wm_padding'] = '20'; $this->image_lib->initialize($config); $this->image_lib->watermark(); This is water mark code in php, it is working fine when we add text to curve image like mug image, the letter is not overlap the curved image how can we overcome?

    Read the article

  • PHP - string to image only produces black background

    - by Phil Jackson
    Hi im really having a problem find how to fix this. $string = "foo"; $font = 4; $width = ImageFontWidth($font) * strlen($string); $height = ImageFontHeight($font); $im = @imagecreatetruecolor ($width,$height); $bg = imagecolorallocate($im, 255, 255, 255); $textcolor = imagecolorallocate($im, 0, 0, 0); imagestring($im, 5, 0, 0, $string, $textcolor); imagegif($im, 'somefile.gif', 8); imagedestroy($im); I cannot seem to change the background from black. Does anyone have any ideas?

    Read the article

  • Right align text in an image with imagettftext(), PHP

    - by James Simpson
    I am setting up dynamic forum signature images for my users and I want to be able to put their username on the image. I am able to do this just fine, but since usernames are different lengths and I want to right align the username, how can I go about doing this when I have to set x & y coordinates. $im = imagecreatefromjpeg("/path/to/base/image.jpg"); $text = "Username"; $font = "Font.ttf"; $black = imagecolorallocate($im, 0, 0, 0); imagettftext($im, 10, 0, 217, 15, $black, $font, $text); imagejpeg($im, null, 90);

    Read the article

  • In PHP, imagepng() accepts a filter parameter. How do these filters affect the function's output?

    - by Joe Lencioni
    How do these filters affect the output of imagepng() in PHP? PNG_NO_FILTER PNG_FILTER_NONE PNG_FILTER_SUB PNG_FILTER_UP PNG_FILTER_AVG PNG_FILTER_PAETH PNG_ALL_FILTERS The documentation simply says, "A special PNG filter, used by the imagepng() function" for each of them. It seems that using PNG_NO_FILTER will reduce the filesize of the output, but other than that, I am unsure as to how it is affected. Any insight would be really appreciated.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >