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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:11:09+00:00 2026-05-28T08:11:09+00:00

i have this script for pixelize my images the script is working but i

  • 0

i have this script for pixelize my images the script is working but i want more smooth edges:

$imgfile = 'batman.jpg';
$image = ImageCreateFromJPEG($imgfile);
$imagex = imagesx($image);
$imagey = imagesy($image);
$pixelate_amount = 10;
$tmpImage = ImageCreateTrueColor($imagex, $imagey);
imagecopyresized($tmpImage, $image, 0, 0, 0, 0, round($imagex / $pixelate_amount), round($imagey / $pixelate_amount), $imagex, $imagey);
$pixelated = ImageCreateTrueColor($imagex, $imagey);
imagecopyresized($pixelated, $tmpImage, 0, 0, 0, 0, $imagex, $imagey, round($imagex / $pixelate_amount), round($imagey / $pixelate_amount));
header("Content-Type: image/jpeg");
imageJPEG($pixelated, "", 100);

I have:

before

this produce:

after

is there anything i miss?

  • 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-28T08:11:10+00:00Added an answer on May 28, 2026 at 8:11 am

    Here’s what you need (script I currently use). This script is based from the script at http://www.talkphp.com/19670-post1.html:

    function convertToPixel($im, $size) {
      $size = (int)$size;
      $sizeX = imagesx($im);
      $sizeY = imagesy($im);
    
      if($sizeX < 3 && $sizeX < 3) { // or you can choose any size you want
        return;
      }
      for($i = 0;$i < $sizeX; $i += $size) {
        for($j = 0;$j < $sizeY; $j += $size) {
          $colors = Array('alpha' => 0, 'red' => 0, 'green' => 0, 'blue' => 0, 'total' => 0);
          for($k = 0; $k < $size; ++$k) {
            for($l = 0; $l < $size; ++$l) {
              if($i + $k >= $sizeX || $j + $l >= $sizeY) {
                continue;
              }
              $color = imagecolorat($im, $i + $k, $j + $l);
              imagecolordeallocate($im, $color);
              $colors['alpha'] += ($color >> 24) & 0xFF;
              $colors['red'] += ($color >> 16) & 0xFF;
              $colors['green'] += ($color >> 8) & 0xFF;
              $colors['blue'] += $color & 0xFF;
              ++$colors['total'];
            }
          }
          $color = imagecolorallocatealpha($im,  $colors['red'] / $colors['total'],  $colors['green'] / $colors['total'],  $colors['blue'] / $colors['total'],  $colors['alpha'] / $colors['total']);
          imagefilledrectangle($im, $i, $j, ($i + $size - 1), ($j + $size - 1), $color);
        }
      }
    }
    header('Content-type: image/jpg');
    $im = imagecreatefromjpeg($imgfile);
    convertToPixel($im, 15);
    imagejpeg($im, '', 100);
    

    This will produce:

    smooth

    You can also change the value passed in convertToPixel to modify the pixel size.
    )

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

Sidebar

Related Questions

I have this script at the moment, which changes an image when a thumbnail
i have this script <select> <option value=1>one<img src=star.gif height=15 width=15></img> </option> </select> but it
I have this script that collects data from users and I want to check
I have this script I am working on that utilizes the oCanvas JS Library
I have this script that only lets users enter a single tag but I
I have this script to load some images after page loading is complete I
I have this script working with jquery and uploadify $('#uploader').uploadify({ 'uploader' : '/admin/includes/uploadify/uploadify.swf', 'script'
I have this script to trigger some javascript. But the script does not support
I have this script for Gmail. It runs inside the canvas_frame iframe. I want
i have this script and it works, but not as i expected. I need

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.