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

  • Home
  • SEARCH
  • 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 8905449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:23:49+00:00 2026-06-15T02:23:49+00:00

I am trying to add round corners to a jpeg file, but the problem

  • 0

I am trying to add round corners to a jpeg file, but the problem is that after adding round corners, I am getting a black background color. Somehow I am not able to change it to any other color (white, transparent, red). It just simply shows black background where the image has rounded corners.

The code that I am using is:

<?php

    $image = new Imagick('example.jpg');
    $image->setBackgroundColor("red");
    $image->setImageFormat("jpg");
    $image->roundCorners(575,575);
    $image->writeImage("rounded.jpg");
    header('Content-type: image/jpeg');
    echo $image;

?>

I cannot use png as the jpeg files are huge, about 5 MB, so if I used png, the file size would go up to 26 MB, even though the png adds transparent round corners.

Also the IMagick version that i am using is:

ImageMagick 6.6.2-10 2010-06-29 Q16 http://www.imagemagick.org 

Also the output(image generated) will get printed so I don’t know if css will work over here.

Sorry, I am trying to actually create a new jpeg file with rounded corners from an already existing jpeg file that doesn’t have round corners this is actually a photograph taken from a camera, so there are multiple/too many colors so I can’t use gif as well.

Also my site will only just generate the round corner image then afterwards it will get downloaded using a FTP program by the admin of the site and then using a system software will get printed, so in short my website will not be printing the image but rather just generate 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-06-15T02:23:50+00:00Added an answer on June 15, 2026 at 2:23 am

    Try this:

    <?php 
    $input = 'example.jpg';
    $size = getimagesize($input);
    $background = new Imagick();
    $background->newImage($size[0], $size[1], new ImagickPixel('red'));
    $image = new Imagick($input);
    $image->setImageFormat("png");
    $image->roundCorners(575,575);
    $image->compositeImage($background, imagick::COMPOSITE_DSTATOP, 0, 0);
    $image->writeImage("rounded.jpg");
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a task - add round corners to HtmlPanelGrid. Now I am trying
I'm trying to add elements to an array after subsequent trials, but so far
Im new to asp.net mvc. I'm trying add new model class but it got
Trying to add a blank sample app for a rails tutorial to GitHub, but
Trying to add a class object into a List using reflection, but when invoking
Possible Duplicate: XNA - File not found problem Here I am trying to load
I'm trying to build a type of calculator that will add and multiply certain
I am trying to add round corner to UISearchBar at the top-left and top-right
trying to add a sub query that only shows records from the last calendar
Trying to get my head round automapping. I am having a problem when trying

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.