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 6143351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:30:52+00:00 2026-05-23T18:30:52+00:00

I have a transparent png image that I would like to make a copy

  • 0

I have a transparent png image that I would like to make a copy of then crop to a 1×1 transparent image.

I’m stuck on the “crop to a 1×1 transparent image” part.

I can either modify the existing image or create new image and overwrite the existing one. I believe both options would work. I’m just not sure how to do either and end up with a 1×1 pixel transparent png image.

Any help much appreciated.

function convertImage(){
    $file1 = "../myfolder/image.png";
    $file2 = "../myfolder/image-previous.png";

    if (!file_exists($file2)) 
        {
        //make a copy of image.png and name the resulting file image-previous.png
        imagecopy($file2, $file1);

        // convert image.png to a 1x1 pixel transparent png 
        // OR 
        // create a new 1x1 transparent png and overwrite image.png with it
        ???

        }
}
  • 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-23T18:30:54+00:00Added an answer on May 23, 2026 at 6:30 pm

    Make use of the imagecopyresized method that PHP has for you.

    More information about imagecopyresized

    Example:

    $image_stats = GetImageSize("/picture/$photo_filename");    
    $imagewidth = $image_stats[0];    
    $imageheight = $image_stats[1];    
    $img_type = $image_stats[2];    
    $new_w = $cfg_thumb_width;    
    $ratio = ($imagewidth / $cfg_thumb_width);    
    $new_h = round($imageheight / $ratio);
    
    // if this is a jpeg, resize as a jpeg
    if ($img_type=="2") {    
        $src_img = imagecreatefromjpeg("/picture/$photo_filename");    
        $dst_img = imagecreate($new_w,$new_h);    
        imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
    
        imagejpeg($dst_img, "/picture/$photo_filename");
    }
    // if image is a png, copy it as a png
    else if ($img_type=="3") {
        $dst_img=ImageCreate($new_w,$new_h);
        $src_img=ImageCreateFrompng("/picture/$photo_filename");
        imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
    
        imagepng($dst_img, "/picture/$photo_filename");
    }
    else ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two png image files that I would like my android app to
I have a png image with white edges. I would like to make the
I have a button that uses a stretchable PNG as the background image, like
I would like a div to have a transparent background. I tried to do
I can have a string that looks like this as an example: sometext<a title=Wink><img
Using the HTML5 <canvas> element, I would like to load an image file (PNG,
Is there any software, plugin or technique that would allow creating/exporting PNG-like GIFs with
I would like to have opaque text within my transparent box. Here is a
Today I was designing a transparent PNG background that would only sit in the
I would like to have a button with the shape of its icon image

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.