Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 517997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:53:31+00:00 2026-05-13T07:53:31+00:00

I am trying to functions: 1. imagecreatefrompng 2. imagepng my php code looks like

  • 0

I am trying to functions:
1. imagecreatefrompng 2. imagepng

my php code looks like this:

<?php
ini_set('memory_limit', -1);

try{
    //if(!$image=imagecreatefromjpeg('zee3.jpg')){
   if(!$image=imagecreatefrompng('leo.png')){
      throw new Exception('Error loading image');
   }
   imagepng($image, 'leoAfter_9compression1.png', 9);
   // free up memory
   imagedestroy($image);
}
catch(Exception $e){
   echo $e->getMessage();
   exit();
}

ini_restore('memory_limit');

?>

The image leo.png a 3MB file

But after running the code leoAfter_9compression1.png image come out to be 1.7MB file. but it is getting cropped. Which i do not want.

And i am unable to understand why is that happening.

Can someone tell me the reason to image getting cropped, and how can i avoid it.

If someone wants to test for the image i am talking about, search “image” leo.png on google. it will the first image on the search.
The image gets cropped as well as distorted.
But i tried the same algorithm for a different image, and its works fine on that.

Regards
Zeeshan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:53:31+00:00Added an answer on May 13, 2026 at 7:53 am

    It shouldn’t, check the original image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to define functions on a object within a prototype like in this
I'm trying to call functions through their pointers. Compiling this code, I get errors
Trying to get my css / C# functions to look like this: body {
I have this piece of code here imagecopyresampled($new_image,$image,0,0,$x,$y,$thumb_width,$thumb_width,$width,$height); Baiscally what I am trying to
I'm trying to extract functions and function headers from some source code files. Here's
I am trying to write a small php function to take an image and
I've been trying to resize an image using php but I'm having issues getting
I'm trying to build a function that takes a PHP image resource and places
Hi i'm trying to upload an image using a php script. And whats really
I'm trying to provide functions in everyone's pocket of nowjs. I'd like to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.