PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 11, 2022

[FIXED] how to create 8bit jpeg in gd using php

 October 11, 2022     gd, jpeg, php     No comments   

Issue

I'm trying to figure out if it's possible to save a jpeg as an 8bit version instead of 16 bit or 24 bit.

I'm currently using imagecreate and then saving using imagejpeg but I can't see any parameters in the manual to allow for 8bit versions.

I've searched stackoverflow and php.net I find it hard to believe this isn't something easily achievable..

Thanks in advance


Solution

Have you tried imagemagic:

convert SRC.jpg -depth 8 -normalize  DEST.jpg

and with PHP:

<?php
error_reporting(E_ALL);
$SRC = 'src.jpg';
$DEST = 'dest.jpg';
$handle = popen("convert $SRC -depth 8 -normalize $DEST 2>&1", 'r');
$read = fread($handle, 2096);
pclose($handle);
?>


Answered By - nad2000
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing