Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/08/2013, 07:43
xoceunder
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 759
Antigüedad: 11 años, 11 meses
Puntos: 10
hacer redimensionar en imagen

hola es que estoy teniendo este problema

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4467152 bytes) in C:\AppServ\www\peniel\includes\Imagen.class.php on line 26

y mi codigo Imagen.class.php

Código PHP:
Ver original
  1. <?php
  2. class SimpleImage {
  3.  
  4.    
  5.  
  6.    var $image;
  7.  
  8.    var $image_type;
  9.  
  10.    function load($filename) {
  11.  
  12.       $image_info = getimagesize($filename);
  13.  
  14.       $this->image_type = $image_info[2];
  15.  
  16.       if( $this->image_type == IMAGETYPE_JPEG ) {
  17.  
  18.          $this->image = imagecreatefromjpeg($filename);
  19.  
  20.       } elseif( $this->image_type == IMAGETYPE_GIF ) {
  21.  
  22.          $this->image = imagecreatefromgif($filename);
  23.  
  24.       } elseif( $this->image_type == IMAGETYPE_PNG ) {
  25.  
  26.          $this->image = imagecreatefrompng($filename);
  27.  
  28.       }
  29.  
  30.    }
  31.  
  32.    function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
  33.  
  34.       if( $image_type == IMAGETYPE_JPEG ) {
  35.  
  36.          imagejpeg($this->image,$filename,$compression);
  37.  
  38.       } elseif( $image_type == IMAGETYPE_GIF ) {
  39.  
  40.          imagegif($this->image,$filename);        
  41.  
  42.       } elseif( $image_type == IMAGETYPE_PNG ) {
  43.  
  44.          imagepng($this->image,$filename);
  45.  
  46.       }  
  47.  
  48.       if( $permissions != null) {
  49.  
  50.          chmod($filename,$permissions);
  51.  
  52.       }
  53.  
  54.    }
  55.    
  56.    function output($image_type=IMAGETYPE_JPEG) {
  57.  
  58.       if( $image_type == IMAGETYPE_JPEG ) {
  59.  
  60.          imagejpeg($this->image);
  61.  
  62.       } elseif( $image_type == IMAGETYPE_GIF ) {
  63.  
  64.          imagegif($this->image);        
  65.  
  66.       } elseif( $image_type == IMAGETYPE_PNG ) {
  67.  
  68.          imagepng($this->image);
  69.  
  70.       }  
  71.  
  72.    }
  73.  
  74.    function getWidth() {
  75.  
  76.       return imagesx($this->image);
  77.  
  78.    }
  79.  
  80.    function getHeight() {
  81.  
  82.       return imagesy($this->image);
  83.  
  84.    }
  85.  
  86.    function resizeToHeight($height) {
  87.  
  88.       $ratio = $height / $this->getHeight();
  89.  
  90.       $width = $this->getWidth() * $ratio;
  91.  
  92.       $this->resize($width,$height);
  93.  
  94.    }
  95.  
  96.    function resizeToWidth($width) {
  97.  
  98.       $ratio = $width / $this->getWidth();
  99.  
  100.       $height = $this->getheight() * $ratio;
  101.  
  102.       $this->resize($width,$height);
  103.  
  104.    }
  105.  
  106.    function scale($scale) {
  107.  
  108.       $width = $this->getWidth() * $scale/100;
  109.  
  110.       $height = $this->getheight() * $scale/100;
  111.  
  112.       $this->resize($width,$height);
  113.  
  114.    }
  115.  
  116.    function resize($width,$height) {
  117.  
  118.       $new_image = imagecreatetruecolor($width, $height);
  119.  
  120.       imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
  121.  
  122.       $this->image = $new_image;  
  123.  
  124.    }      
  125.  
  126. }
  127.  
  128. ?>

que puede ser el eror