mike42 / gfx-php Goto Github PK
View Code? Open in Web Editor NEWThe pure PHP graphics library
Home Page: https://gfx-php.readthedocs.io/
License: GNU Lesser General Public License v2.1
The pure PHP graphics library
Home Page: https://gfx-php.readthedocs.io/
License: GNU Lesser General Public License v2.1
Read raster data a from a PNG file into the most appropriate raster image format.
For the initial implementation, flatten RGBA data to RGB by mixing with white.
Test file collections:
test/resources/pygif/max-width.gif: BC.Gif.Exploit.Agent-1425366.Agent
Add a new RasterImage
implementation to access an indexed raster image.
It needs to have colors stored via a numeric index. The index will be re-sizable up to some per-instance limit, or 256 colors by default. The palette color space should be 4 byte RGBA.
Logical order to implement this:
toIndexed()
returning a new indexed raster image from existing implementationsAdd a sample of benchmarks to the code via phpbench.
This should enable us to evaluate the performance impact of changes over time.
When an image is saved with a 'bmp' extension, encode it as a 24 bit per pixel BMP image.
The file should be readable by ImageMagick, GIMP, and bmptoppm.
Blocked by #14.
Project is currently image-php
, which is confusingly similar to the existing php-image
package.
Rename to gfx-php
and fix breakages (easier while it's new).
The BMP output is not understood by some readers, which report that the file is invalid.
For example, taking this sample image:
<?php
require_once(__DIR__ . "/../vendor/autoload.php");
use Mike42\GfxPhp\Image;
// Write abc.png out as BMP
$img = Image::fromFile(dirname(__FILE__). "/resources/abc.png");
$img -> write("abc.bmp");
The resulting BMP is understood by some readers, but gimp
and ImageMagick
convert it back to PNG like this:
$ convert abc.bmp abc.png
convert-im6.q16: length and filesize do not match `abc.bmp' @ warning/bmp.c/ReadBMPImage/842.
$ file abc.bmp
abc.bmp: PC bitmap, Windows 3.x format, 40 x 40 x 24
$ hexdump -C abc.bmp
00000000 42 4d 00 00 00 00 00 00 00 00 00 00 00 00 28 00 |BM............(.|
00000010 00 00 28 00 00 00 28 00 00 00 01 00 18 00 00 00 |..(...(.........|
00000020 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 |................|
00000030 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff |................|
00000040 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00000120 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ec |................|
00000130 c3 df b0 00 7a b0 00 7a b0 00 7a b0 02 7b b4 0e |....z..z..z..{..|
00000140 81 bc 28 8e cc 5c a9 e7 b2 d6 fe fe fe ff ff ff |..(..\..........|
00000150 ff ff ff ff ff ff ff ff ff c3 ea ec 00 a7 b0 00 |................|
00000160 a7 b0 00 a7 b0 00 a7 b0 00 a7 b0 00 a7 b0 00 a7 |................|
00000170 b0 00 a7 b0 c7 eb ed ff ff ff ed ed c3 b6 b6 00 |................|
00000180 d6 d6 73 ff ff ff ff ff ff ff ff ff ff ff ff ff |..s.............|
...
Currently, we can write BMP files, but cannot read them.
Implement a BMP decoder. This will also require RLE decoding, and some logic to map the variety of colour modes to simple RGB.
Best test suite available is bmpsuite, which appears to be under a suitable license (see README here).
Image files generated by this program are not covered by this license, and are
in the public domain (except for the embedded ICC profiles).
We have the ability to read and write all three of these formats.
Two known issues from using this library on newer PHP versions.
BlackAndWhiteRasterImage.php
, line 20.Write GIF output.
Because we don't have support for indexed raster images, save as monocrome, since it will align with a hard-coded palette of 256 entries (0, 0, 0)
to (255, 255, 255)
.
The test file 4095-codes.gif
is valid, but will cause the LZW decoder in gfx-php
to throw an Exception.
There is a skipped test called test_4095_codes
. Fix the LZW decoder and enable this test.
It's currently possible to convert a black/white raster image to text.
Write an output codec for printing an image as ANSI (for command-line use).
This is a color bitmap format.
Write an encoder which can create PNG files (RGB format, compress with zlib
).
I noticed a regression in 0.4.1 where HHVM no longer worked (hhvm-3.21
there).
Both hhvm-3.21
and hhvm-3.27
are likely to work with minor changes to error handling. Later versions drop PHP support, so this is expected to be a fairly temporary part of the project.
This is a monochrome format which was designed by the web but is not widely used. It is mentioned in the PHP GD docs, works with the ImageMagick command-line.
The format is a header around uncompressed 1-bit raster data, which is apparently understood directly by some printers.
convert foo.png foo.wbmp
Find a way to automatically generate and host documentation with each release.
Changes necessary to get build/test rolling again for next release.
"phpunit/phpunit": "^6.5",
"squizlabs/php_codesniffer": "^3.3.1",
"phpbench/phpbench": "@dev"
Read raster data and palette from a GIF file into an indexed raster image.
If multiple images are stored in the GIF, then retrieve the first one only.
Need indexed raster image implementation at #14
Test file collections:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.