Search Results

Search found 50 results on 2 pages for 'getimagesize'.

Page 1/2 | 1 2  | Next Page >

  • PHP problem with getimagesize()

    - by RobHardgood
    I'm using the getimagesize() function in PHP and it keeps returning an error: getimagesize(image.php?name=username&pic=picture) [function.getimagesize]: failed to open stream: No such file or directory I'm not doing anything strange with it. The only problem I can imagine is that the path URL is another PHP script that returns a page with an image header, and there is an ampersand in that URL. Here is my code: $location = "image.php?name=username&pic=picture"; $size = getimagesize($location);

    Read the article

  • PHP getimagesize with ampersand in string creates errors

    - by RobHardgood
    I'm using the getimagesize function in PHP, and the path string contains an ampersand, which otherwise is fine. The page gives me errors where getimagesize() is called. Looking at the source code, though, I see the ampersand is being passed through as & rather than just & I presume this is causing errors because PHP doesn't need to convert it to the html tag in order to find the path, right? Here is the error: Warning: getimagesize(image.php?name=username&pic=picture) [function.getimagesize]: failed to open stream: No such file or directory

    Read the article

  • Super fast getimagesize in php

    - by Sir Lojik
    Hi all, im trying to get image size(DIMENSIONS) of hundreds of remote images and getimagesize is way too slow. ive done some reading and found out the quickest way would be to use get_file_contents to read a certain aount of bytes from the images and examining the size within the binary data. Anyone attempted this before? How would i examine different formats. Seen any library for this? please let me know

    Read the article

  • PHP getimagesize is not working when is called from a function in function.php (Wordpress)?

    - by janoChen
    PHP getimagesize is not working when is called from a function in function.php. function.php: add_action('wp_head', 'get_image_size'); function get_image_size() { global $width; // I thought this would solve the problem but it didn't global $height; // I thought this would solve the problem but it didn't list($width, $height, $type, $attr) = getimagesize($options['logo']); echo "Image width " .$width; echo "<BR>"; echo "Image height " .$height; echo "<BR>"; } $options['logo'] is returning http://localhost/wordpress/wp-content/uploads/2010/12/logo4.png so the image is being displayed. I also did var_dump to $width and $height but they didn't show up. Any suggestions?

    Read the article

  • Generate image with Drupal imagecache before using imagecache_create_path & getimagesize

    - by ozke
    Hi guys, I'm using imagecache_create_path() and getimagesize() to get the path of a imagecache-generated image and its dimensions. However, if it's the first time we access the page that image doesn't exist yet and imagecache_create_path doesn't generate it either. Here's the code: // we get the image path from a preset (always return the path even if the file doesn't exist) $small_image_path = imagecache_create_path('gallery_image_small', $image["filepath"]); // I get the image dimensions (only if the file exists already) $data_small = list($width, $height, $type, $image_attributes) = @getimagesize($small_image_path); Is there any API method to get the path AND generate the file? In other words, can I generate the image (using a preset) from PHP without showing it in the browser? Thank you in advance

    Read the article

  • getimagesize on alfresco image

    - by SupFrig
    i'm working on a front display for an alfresco filled with pictures. i'm building my pictures url like this : http://myHost.com:8080/share/proxy/alfresco-noauth/api/node/content/workspace/SpacesStore/bf0a8b21-b8d9-487d-a529-dee8c49d7c6f/filetitle.jpg?alf_ticket=myTicket where myHost is the server and myTicket is the ticket generated at this url : http://myHost.com:8080/alfresco/service/api/login?u=login&pw=password Picture is displaying correctly with this url, but i want to use phpthumb to resize it, and when i try to use it on my picture, i get an http 500 error on the script and the following log : PHP Warning: getimagesize(http://myHost.com:8080/share/proxy/alfresco-noauth/api/node/content/workspace/SpacesStore/bf0a8b21-b8d9-487d-a529-dee8c49d7c6f/filetitle.jpg?alf_ticket=myTicket): failed to open stream: HTTP request failed! HTTP/1.1 401 Non-Autorisé I shouldn't hit the authentification, since my link has a valid ticket (I don't hit authentification when i display normally my picture)

    Read the article

  • Using max-width = 100% and max-height = 100% on an image, calculate the display width/height

    - by NatalieMac
    I am creating a slideshow for images of various sizes to display centered vertically and horizontally within a canvas area. In my CSS, I set the width and height of the image to 100% so that each image would proportionally fill the canvas. I want the canvas to auto-size itself to fit within the viewer's screensize as the original size of the images is quite large (up to 800 pixels tall). I am using jQuery 1.4, and using the height of the image to calculate the top value for absolute positioning it to the middle of the canvas. I have tried using jQuery to get the .height(), innerHeight(), and outerHeight(), but it always gets the full size of the image. I extracted the DOM element from the jQuery object and tried using .width, .offsetWidth, and .clientWidth, but that too always seems to return the full size of the image. Firebug displays the correct dimensions, so I know there's some way of calculating the actual display height of the image, I just can't figure out what it is. How do you get the actual display height of an image if you've set max-height = 100%? I didn't want to have to calculate and set the height of each image in the js, but if I have to, I will. It just seems like I should be able to set the canvas size and have the images auto-adjust.

    Read the article

  • How to get the height of an Image in Silverlight?

    - by Edward Tanguay
    I have this code in Silverlight: Image image = new Image(); BitmapImage bitmapImage= TheDatasourceManager.GetBitmapImage("blackPencil"); image.Source = bitmapImage; image.Stretch = Stretch.None; image.HorizontalAlignment = HorizontalAlignment.Left; image.VerticalAlignment = VerticalAlignment.Top; image.Margin = new Thickness(88, 88, 0, 0); grid.Children.Add(image); Now I want to find out the height of the image. in WPF I can get it with image.Source.Height but this is not available in Silverlight bitmapImage.Height doesn't exist either when I debug and examine the image object, I eventually get to PixelHeight which has an accurate height, but I can't seem to access it I find image.ActualHeight but it is 0. How can I get the height of the image?

    Read the article

  • What is the simplest way to download file in PHP

    - by silent
    Hi all, I need to download an image from some URL to my server. However, my server's config disallowed me to do it this way: getimagesize( $file ); Because, it generate error: Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in somefile.php on line 10 So, is there another way I can use that doesn't require external library?

    Read the article

  • d13slideshow for WordPress and "URL file-access is disabled"

    - by windyjonas
    I'm taking my chances with WordPress 3.0 beta 1 (single user) Unfortunately, i ran into problems with d13slideshow. I configured the plugin to display 5 latest from a category, added <?php d13slideshow(); ?> to home.php, but it bombed: function.getimagesize: URL file-access is disabled in the server configuration in /<snip>/wp-content/plugins/d13slideshow/d13slideshow.php on line 538 Warning: getimagesize(http://<snip>/wp-content/uploads/2010/04/featured-2-580x386.jpg) function.getimagesize: failed to open stream: no suitable wrapper could be found in /<snip>/wp-content/plugins/d13slideshow/d13slideshow.php on line 538 Is this a problem with the php setup or is there something I can do with the plugin or the function call from the template files to make it work? http://wordpress.org/extend/plugins/d13slideshow/

    Read the article

  • Image Resizing: Poor jpeg quality and black PNG backgrounds

    - by azz0r
    Hello, I have two issues with my class, basically the quality of the jpeg images is quite poor, but I'm not sure if thats down to my ratio resizing. Ideally I'd like this class to be strict with image sizes and crop into them, but I cant get my head around it. My main issue is that pngs always have a black bg, does anyone have experience with this happening? <?php class OpenSource_ImageResize { function __construct($theFile, $toWhere, $mime, $extension, $newWidth, $newHeight) { if ($mime == NULL) { $mime = getimagesize($theFile); $mime = $mime['mime']; } if ($mime == 'image/jpeg') { $size = getimagesize($theFile); if ($size[0] > $newWidth || $size[1] > $newHeight) { $sourceImage = imagecreatefromjpeg($theFile); } else { return copy($theFile, $toWhere); throw new exception('Could not create jpeg'); return false; } } else if ($mime == 'image/png') { $size = getimagesize($theFile); if ($size[0] > $newWidth || $size[1] > $newHeight) { $sourceImage = imagecreatefrompng($theFile); } else { return copy($theFile, $toWhere); //throw new exception('Could not create png'); return false; } } else if ($mime == 'image/gif') { $size = getimagesize($theFile); if ($size[0] > $newWidth || $size[1] > $newHeight) { $sourceImage = imagecreatefromgif ($theFile); } else { return copy($theFile, $toWhere); //throw new exception('Could not create gif'); return false; } } else { throw new exception('Not a valid mime type'); return false; } $oldX = imageSX($sourceImage); $oldY = imageSY($sourceImage); if ($newWidth == NULL) { $thumbHeight = $newHeight; $thumbWidth = round($newHeight/($oldY/$oldX)); } else if ($oldX > $oldY) { $thumbWidth = $newWidth; $thumbHeight = $oldY * ($newHeight/$oldX); } if ($oldX < $oldY) { $thumbWidth = round($newHeight/($oldY/$oldX)); $thumbHeight = $newHeight; } if ($oldX == $oldY) { $thumbWidth = $newWidth; $thumbHeight = $newHeight; } if (!gd_info()) { $dstImage = ImageCreate($thumbWidth, $thumbHeight); imagecopyresized($dstImage, $sourceImage, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $oldX, $oldY); } else { $dstImage = ImageCreateTrueColor($thumbWidth, $thumbHeight); imagecopyresampled($dstImage, $sourceImage, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $oldX, $oldY); } if ($mime == 'image/png') { $xparent = imagecolorresolvealpha($dstImage, 255,2,240, 0) ; imagecolortransparent($dstImage,$xparent); imagealphablending($dstImage,true); imagepng($dstImage, $toWhere); } else if ($mime == 'image/jpeg') { imagejpeg($dstImage, $toWhere); } else if ($mime == 'image/gif') { imagegif ($dstImage, $toWhere); } imagedestroy($dstImage); imagedestroy($sourceImage); return true; } }

    Read the article

  • getimagezise Error pasing filename

    - by Talha Bin Shakir
    Hi, I am using getimagesize() to get teh size of my image. I have image in my sub-directory when i am passing file name with sub-directory i ma facing an error: There is no such file or directory here is my Code: <?PHP function resize($img,$max_w){ $max_h=$max_w; list($img_w,$img_h) = getimagesize($img); $f = min($max_w/$img_w, $max_h/$img_h, 1); $w = round($f * $img_w); $h = round($f * $img_h); return array($w,$h); } $filename="user_img/"."1256115556.jpg"; $resize=resize($filename,667); $w=$resize[0]; $h=$resize[1]; ?> instead of this when i passing $filename="1256115556.jpg"; file from my main directory the function is running perfectly. So please help me, How to pass file with sub-directory.

    Read the article

  • Loopback connection via PHP's getimage size crashes server (Magento's CMS)

    - by Alex
    We were able to trace down a problem that is crashing our NGINX server running Magento until the following point: Background info: Magento Backend has a CMS function with a WYSIWYG editor. This editor loads some pictures via a controller in magento (cms/directive). When we set the NGINX error_log level to info, we get the following lines (line break inserted for better readability): 2012/10/22 18:05:40 [info] 14105#0: *1 client closed prematurely connection, so upstream connection is closed too while sending request to upstream, client: XXXXXXXXX, server: test.local, request: "GET index.php/admin/cms_wysiwyg/directive/___directive/BASEENCODEDIMAGEURL,,/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9024", host: "test.local" When checking the code in the debugger, the following call does never return (in ´Varien_Image_Adapter_Abstract::getMimeType()` # $this->_fileName is http://test.local/skin/adminhtml/base/default/images/demo-image-not-existing.gif` # $_SERVER['REQUEST_URI'] = http://test.local/admin/cms_wysiwyg/directive/___directive/BASEENCODEDIMAGEURL list($this->_imageSrcWidth, $this->_imageSrcHeight, $this->_fileType, ) = getimagesize($this->_fileName); The filename requests is an URL to the same server which is requesting the script a link to a static .gif that is not existing. Sample URL: http://test.local/skin/adminhtml/base/default/images/demo-image-not-existing.gif When the above line executed, any subsequent request to the NGNIX server does not respond any more. After waiting for around 10 minutes, the NGINX server starts answering requests again. I tried to reproduce the error with a simple test script that only calls getimagesize() with the given URL - but this not crash. It simple leads to an exception saying that the URL could not be loaded (which is fine as the URL is wrong)

    Read the article

  • Nginx: Loopback connection via PHP's getimage size crashes server (Magento's CMS)

    - by Alex
    We were able to trace down a problem that is crashing our NGINX server running Magento until the following point: Background info: Magento Backend has a CMS function with a WYSIWYG editor. This editor loads some pictures via a controller in magento (cms/directive). When we set the NGINX error_log level to info, we get the following lines (line break inserted for better readability): 2012/10/22 18:05:40 [info] 14105#0: *1 client closed prematurely connection, so upstream connection is closed too while sending request to upstream, client: XXXXXXXXX, server: test.local, request: "GET index.php/admin/cms_wysiwyg/directive/___directive/BASEENCODEDIMAGEURL,,/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9024", host: "test.local" When checking the code in the debugger, the following call does never return (in ´Varien_Image_Adapter_Abstract::getMimeType()` # $this->_fileName is http://test.local/skin/adminhtml/base/default/images/demo-image-not-existing.gif` # $_SERVER['REQUEST_URI'] = http://test.local/admin/cms_wysiwyg/directive/___directive/BASEENCODEDIMAGEURL list($this->_imageSrcWidth, $this->_imageSrcHeight, $this->_fileType, ) = getimagesize($this->_fileName); The filename requests is an URL to the same server which is requesting the script a link to a static .gif that is not existing. Sample URL: http://test.local/skin/adminhtml/base/default/images/demo-image-not-existing.gif When the above line executed, any subsequent request to the NGNIX server does not respond any more. After waiting for around 10 minutes, the NGINX server starts answering requests again. I tried to reproduce the error with a simple test script that only calls getimagesize() with the given URL - but this not crash. It simple leads to an exception saying that the URL could not be loaded (which is fine as the URL is wrong)

    Read the article

  • PHP image watermark only displaying image on page

    - by Satch3000
    I am testing a script where I watermark an image in my webpage. The script works fine and the image is watermark but my problem is that only the image is displayed on the page. As soon as I add the script to my page it's like the web page is converted to the image that I'm watermarking. I think it's because of header("content-type: image/jpeg"); from the code. I need to watermark the image on my webpage but I also need the rest of my webpage to be displayed too. How is this done? I'm quite confused on how this works. The script I'm using is from here Here's the code I'm using: <?php $main_img = "Porsche_911_996_Carrera_4S.jpg"; // main big photo / picture $watermark_img = "watermark.gif"; // use GIF or PNG, JPEG has no tranparency support $padding = 3; // distance to border in pixels for watermark image $opacity = 100; // image opacity for transparent watermark $watermark = imagecreatefromgif($watermark_img); // create watermark $image = imagecreatefromjpeg($main_img); // create main graphic if(!$image || !$watermark) die("Error: main image or watermark could not be loaded!"); $watermark_size = getimagesize($watermark_img); $watermark_width = $watermark_size[0]; $watermark_height = $watermark_size[1]; $image_size = getimagesize($main_img); $dest_x = $image_size[0] - $watermark_width - $padding; $dest_y = $image_size[1] - $watermark_height - $padding; // copy watermark on main image imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $opacity); // print image to screen header("content-type: image/jpeg"); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); ?> NOTE: I'm getting the image path from the database so I cannot hardcode the image filename as it's dynamic.

    Read the article

  • php adding images to another image, exact positioning

    - by user271619
    I have a cool snippet of code that works well, except one thing. The code will take an icon I want to add to an existing picture. I can position it where I want too! Which is exactly what I need to do. However, I'm stuck on one thing, concerning the placement. The code "starting position" (on the main image: navIcons.png) is from the Bottom Right. I have 2 variables: $move_left = 10; & $move_up = 8;. So, the means I can position the icon.png 10px left, and 8px up, from the bottom right corner. I really really want to start the positioning from the Top Left of the image, so I'm really moving the icon 10px right & 8px down, from the top left position of the main image. Can someone look at my code and see if I'm just missing something that inverts that starting position? function attachIcon($imgname) { $mark = imagecreatefrompng($imgname); imagesavealpha($mark, true); list($icon_width, $icon_height) = getimagesize($imgname); $img = imagecreatefrompng('images/sprites/navIcons.png'); imagesavealpha($img, true); $move_left = 10; $move_up = 9; list($mainpic_width, $mainpic_height) = getimagesize('images/sprites/navIcons.png'); imagecopy($img, $mark, $mainpic_width-$icon_width-$move_left, $mainpic_height-$icon_height-$move_up, 0, 0, $icon_width, $icon_height); imagepng($img); // display the image + positioned icon in the browser //imagepng($img,'newnavIcon.png'); // rewrite the image with icon attached. } header('Content-Type: image/png'); attachIcon('icon.png'); ? For those who are wondering why I'd even bother doing this. In a nutshell, I like to add 16x16 icons to 1 single image, while using css to display that individual icon. This does involve me downloading the image (sprite) and open photoshop, add the new icon (positioning it), and reuploading it to the server. Not a massive ordeal, but just having fun with php.

    Read the article

  • Extract new image dimensions from timthumb

    - by jonthoughtit
    I'm using timthumb to resize my images because it scales them nicely if I only enter one of the dimensions. However I want to know if it's possible to extract the new resized image's dimensions so that I can add that dynamically to the img tag attributes. I tried this with no luck: $fullpath = '/lib/timthumb.php?src='.$image.'&w=100'; $my_image = array_values(getimagesize($fullpath)); list($width, $height, $type, $attr) = $my_image; Any ideas?

    Read the article

  • PHP Image resize - Why is the image uploaded but not resized?

    - by Hans
    BACKGROUND I have a script to upload an image. One to keep the original image and one to resize the image. 1. If the image dimensions (width & height) are within max dimensions I use a simple "copy" direct to folder UserPics. 2. If the original dimensions are bigger than max dimensions I want to resize the width and height to be within max. Both of them are uploading the image to the folder, but in case 2, the image will not be resized. QUESTION Is there something wrong with the script? Is there something wrong with the settings? SETTINGS Server: WAMP 2.0 PHP: 5.3.0 PHP.ini: GD2 enabled, Memory=128M (have tried 1000M) Tried imagetypes uploaded: jpg, jpeg, gif, and png (same result for all of them) SCRIPT //Uploaded image $filename = stripslashes($_FILES['file']['name']); //Read filetype $i = strrpos($filename,"."); if (!$i) { return ""; } $l = strlen($filename) - $i; $extension = substr($filename,$i+1,$l); $extension = strtolower($extension); //New picture name = maxid+1 (from database) $query = mysql_query("SELECT MAX(PicId) AS number FROM userpictures"); $row = mysql_fetch_array($query); $imagenumber = $row['number']+1; //New name of image (including path) $image_name=$imagenumber.'.'.$extension; $newname = "UserPics/".$image_name; //Check width and height of uploaded image list($width,$height)=getimagesize($uploadedfile); //Check memory to hold this image (added only as checkup) $imageInfo = getimagesize($uploadedfile); $requiredMemoryMB = ( $imageInfo[0] * $imageInfo[1] * ($imageInfo['bits'] / 8) * $imageInfo['channels'] * 2.5 ) / 1024; echo $requiredMemoryMB."<br>"; //Max dimensions that can be uploaded $maxwidth = 20; $maxheight = 20; // Check if dimensions shall be original if ($width > $maxwidth || $height > $maxheight) { //Make jpeg from uploaded image if ($extension=="jpg" || $extension=="jpeg" || $extension=="pjpeg" ) { $modifiedimage = imagecreatefromjpeg($uploadedfile); } elseif ($extension=="png") { $modifiedimage = imagecreatefrompng($uploadedfile); } elseif ($extension=="gif") { $modifiedimage = imagecreatefromgif($uploadedfile); } //Change dimensions if ($width > $height) { $newwidth = $maxwidth; $newheight = ($height/$width)*$newwidth; } else { $newheight = $maxheight; $newwidth = ($width/$height)*$newheight; } //Create new image with new dimensions $newdim = imagecreatetruecolor($newwidth,$newheight); imagecopyresized($newdim,$modifiedimage,0,0,0,0,$newwidth,$newheight,$width,$height); imagejpeg($modifiedimage,$newname,60); // Remove temp images imagedestroy($modifiedimage); imagedestroy($newdim); } else { // Just add picture to folder without resize (if org dim < max dim) $newwidth = $width; $newheight = $height; $copied = copy($_FILES['file']['tmp_name'], $newname); } //Add image information to the MySQL database mysql_query("SET character_set_connection=utf8", $dbh); mysql_query("INSERT INTO userpictures (PicId, Picext, UserId, Width, Height, Size) VALUES('$imagenumber', '$extension', '$_SESSION[userid]', '$newwidth', '$newheight', $size)")

    Read the article

  • PHP Image Link in FUnction 404's

    - by Dave C
    Hello, I have a valid link that goes to a picture located on my web server. It is a simple jpg image, I can copy and paste this link into my web browser and it loads fine. The issue comes in when I try to call a few php functions on the image... such as getimagesize or fopen... they both return 404 errors even though the image is there. Does anyone know that could be causing this? Thank you for your time.

    Read the article

  • PHP GD - How can I modify my Thumbnail Creator to crop portrait images from the center?

    - by frank
    Here is my current code: $image = 'img.jpg'; $source = imagecreatefromjpeg($image); list($origWidth, $origHeight) = getimagesize($image); $imgH = 75; $imgW = $origWidth / $origHeight * $imgH; $thumb = imagecreatetruecolor($imgW, $imgH); imagecopyresampled($thumb, $source, 0, 0, 0, 0, $imgW, $imgH, $origWidth, $origHeight); This allows me to output an image with a fixed height of 75 pixels. What I would like to do is have a constant image size of 99x75 pixels. Portrait images that don't fit into this will be cropped from the center (so the center of the original remains the center of the thumbnail - if that makes sense). How can I do this?

    Read the article

  • Is php fileinfo sufficient to prevent upload of malicious files?

    - by Scarface
    Hey guys, I have searched around a bit, and have not really found a professional type response to how to have secure fileupload capability so I wanted to get the opinion of some of the experts on this site. I am currently allowing upload of mp3s and images, and while I am pretty confident in preventing xss and injection attacks on my site, I am not really familiar with fileupload security. I basically just use php fileinfo and check an array of accepted filetypes against the filetype. For images, there is the getimagesize function and some additional checks. As far as storing them, I just have a folder within my directory, because I want the users to be able to use the files. If anyone could give me some tips I would really appreciate it.

    Read the article

  • why some mp3s on mime_content_type return application/octet-stream

    - by robertdd
    why on some mp3s file when i call mime_content_type($mp3_file_path) it's return application/octet-stream? i have this: if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $image = getimagesize($tempFile); $mp3_mimes = array('audio/mpeg', 'audio/x-mpeg', 'audio/mp3', 'audio/x-mp3', 'audio/mpeg3', 'audio/x-mpeg3', 'audio/mpg', 'audio/x-mpg', 'audio/x-mpegaudio'); if (in_array(mime_content_type($tempFile), $mp3_mimes)) { echo json_encode("mp3"); } elseif ($image['mime']=='image/jpeg') { echo json_encode("jpg"); } else{ echo json_encode("error"); } }

    Read the article

1 2  | Next Page >