Giter VIP home page Giter VIP logo

Comments (9)

verot avatar verot commented on September 27, 2024

I am afraid that there is no easy solution. Either your machine is too slow, or has limited memory, either the image is too big. If you are looking into processing large images, you should look into imagemagick which is faster than GD2.

from class.upload.php.

tiagomaker avatar tiagomaker commented on September 27, 2024

That's weird. Online it happen too, with simple images, but ok.

from class.upload.php.

verot avatar verot commented on September 27, 2024

Care to share the log produced by the class?

from class.upload.php.

tiagomaker avatar tiagomaker commented on September 27, 2024

system information

  • class version : 0.33dev
  • operating system : WINNT
  • PHP version : 5.5.12
  • GD version : 2.1.0
  • supported image types : png jpg gif bmp
  • open_basedir : no restriction
  • upload_max_filesize : 64M (67108864 bytes)
  • language : en_GB
    source is an uploaded file
  • upload OK
  • file name OK
    determining MIME type
  • Checking MIME type with Fileinfo PECL extension
    MAGIC path defaults to E:\wamp\bin\php\php5.5.12/extras/magic
    Fileinfo PECL extension failed (finfo_open)
  • Checking MIME type with UNIX file() command
    UNIX file() command not availabled
  • Checking MIME type with mime.magic file (mime_content_type())
    MIME type detected as image/jpeg by mime_content_type()
  • MIME validated as image/jpeg
    source variables
  • You can use all these before calling process()
    file_src_name : banner.jpg
    file_src_name_body : banner
    file_src_name_ext : jpg
    file_src_pathname : E:\wamp\tmp\php4982.tmp
    file_src_mime : image/jpeg
    file_src_size : 157497 (max= 67108864)
    file_src_error : 0
  • source file is an image
    image_src_x : 1920
    image_src_y : 400
    image_src_pixels : 768000
    image_src_type : jpg
    image_src_bits : 8
    process file to ../uploads/banners/\
  • file size OK
  • file mime OK : image/jpeg
  • file name safe format
  • destination variables
    file_dst_path : ../uploads/banners/
    file_dst_name_body : banner
    file_dst_name_ext : jpg
  • checking for auto_rename
    auto_rename to banner_3.jpg
  • destination file details
    file_dst_name : banner_3.jpg
    file_dst_pathname : ../uploads/banners/\banner_3.jpg
  • banner_3.jpg doesn't exist already
  • image resizing or conversion wanted
  • source image is JPEG
  • setting destination file type to jpg
  • resizing...
    use plain sizes
    resized image object created
    image_src_x y : 1920 x 400
    image_dst_x y : 1920 x 400
  • converting...
    fills in transparency with default color
  • saving image...
    JPEG image created
    image objects destroyed
  • process OK
    cleanup
  • delete temp file E:\wamp\tmp\php4982.tmp

from class.upload.php.

tiagomaker avatar tiagomaker commented on September 27, 2024
if($_FILES['arquivo'] != ''){
  if($_GET['acao'] == 'adicionar'){
      $id = Connection::getInstance()->lastInsertId();
  }
  require_once("class/Upload.class.php");
  $handle = new upload($_FILES['arquivo']);

  if($handle->uploaded){
    $handle->image_resize         = true;
    $handle->image_x              = 1920;
    $handle->image_y              = 400;
    $handle->image_ratio_y        = false;
    $handle->process('../uploads/banners/');

    if($handle->processed) {
      $arquivo = 'uploads/banners/'.$handle->file_dst_name;
      $handle->clean();
      echo $handle->log;
      $acao = Connection::getInstance()->prepare("UPDATE banners SET imagem = :arquivo WHERE id = :id");
      $acao->bindValue(":id", $id);
      $acao->bindValue(":arquivo", $arquivo);
      $acao->execute();

    }
  }
}

from class.upload.php.

verot avatar verot commented on September 27, 2024

1920x400 is unfortunately a fairly large size, and it may explain why the processing is slow. What matters is size in pixels, and that increases exponentially with larger image dimensions. Besides resizing, your process is also a conversion to JPEG, so the class has to fill transparent areas with a background color.
So to me, it looks fairly normal that it may be slow.

from class.upload.php.

tiagomaker avatar tiagomaker commented on September 27, 2024

there's a way to no use the conversion process? Becouse i'm already uploading a jpg file

from class.upload.php.

verot avatar verot commented on September 27, 2024

Not really... But you seem to upload a 1920x400, to get in the end a 1920x400 image. Is that normal? If you have the right resolution from the start, no need to resize obviously...

from class.upload.php.

tiagomaker avatar tiagomaker commented on September 27, 2024

You know... sometimes the users don't read de advice: "PLEASE, UPLOAD A 1920X400 PIXELS IMAGE" ahahah
Fine man, i'll do something. Your class is awesome, too easy to use and so many resource. Thank you for all

from class.upload.php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.