Comments (9)
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.
That's weird. Online it happen too, with simple images, but ok.
from class.upload.php.
Care to share the log produced by the class?
from class.upload.php.
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.
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.
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.
there's a way to no use the conversion process? Becouse i'm already uploading a jpg file
from class.upload.php.
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.
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)
- Notice on imagecolorat() HOT 3
- can support text shadow? HOT 1
- Cyrillic symbols encoding HOT 4
- Text crop HOT 4
- Allowed video/* Doesn't Include MP4 HOT 1
- Bmp format conversion error HOT 3
- Feature: Repeats Watermark HOT 2
- Feature: add support for avif format HOT 3
- Suggestion: filter the content of svg HOT 2
- Multipart upload HOT 1
- Deprecation php8.2 HOT 3
- Composer is not up2date HOT 1
- view image when selected HOT 1
- PHP 8.2 Dynamic property is deprecated
- Security vulnerability disclosure HOT 2
- Found 1 security vulnerability advisory when run Composer audit HOT 2
- Fix security vulnerability related to XSS attacks via uploaded files HOT 1
- Adding Turkish Translation to readme.md
- Vulnerability found in dependency: CVE-2023-6551 5.4 Unrestricted Upload of File with Dangerous Type vulnerability with Medium severity found HOT 3
- Multiple files upload HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from class.upload.php.