{"action":"created","issue":{"url":"https://api.github.com/repos/libgd/libgd/issues/288","repository_url":"https://api.github.com/repos/libgd/libgd","labels_url":"https://api.github.com/repos/libgd/libgd/issues/288/labels{/name}","comments_url":"https://api.github.com/repos/libgd/libgd/issues/288/comments","events_url":"https://api.github.com/repos/libgd/libgd/issues/288/events","html_url":"https://github.com/libgd/libgd/issues/288","id":171069349,"number":288,"title":"GD and GD2 image formats are not documented","user":{"login":"cmb69","id":2306138,"avatar_url":"https://avatars.githubusercontent.com/u/2306138?v=3","gravatar_id":"","url":"https://api.github.com/users/cmb69","html_url":"https://github.com/cmb69","followers_url":"https://api.github.com/users/cmb69/followers","following_url":"https://api.github.com/users/cmb69/following{/other_user}","gists_url":"https://api.github.com/users/cmb69/gists{/gist_id}","starred_url":"https://api.github.com/users/cmb69/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmb69/subscriptions","organizations_url":"https://api.github.com/users/cmb69/orgs","repos_url":"https://api.github.com/users/cmb69/repos","events_url":"https://api.github.com/users/cmb69/events{/privacy}","received_events_url":"https://api.github.com/users/cmb69/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/libgd/libgd/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"cmb69","id":2306138,"avatar_url":"https://avatars.githubusercontent.com/u/2306138?v=3","gravatar_id":"","url":"https://api.github.com/users/cmb69","html_url":"https://github.com/cmb69","followers_url":"https://api.github.com/users/cmb69/followers","following_url":"https://api.github.com/users/cmb69/following{/other_user}","gists_url":"https://api.github.com/users/cmb69/gists{/gist_id}","starred_url":"https://api.github.com/users/cmb69/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmb69/subscriptions","organizations_url":"https://api.github.com/users/cmb69/orgs","repos_url":"https://api.github.com/users/cmb69/repos","events_url":"https://api.github.com/users/cmb69/events{/privacy}","received_events_url":"https://api.github.com/users/cmb69/received_events","type":"User","site_admin":false},"assignees":[{"login":"cmb69","id":2306138,"avatar_url":"https://avatars.githubusercontent.com/u/2306138?v=3","gravatar_id":"","url":"https://api.github.com/users/cmb69","html_url":"https://github.com/cmb69","followers_url":"https://api.github.com/users/cmb69/followers","following_url":"https://api.github.com/users/cmb69/following{/other_user}","gists_url":"https://api.github.com/users/cmb69/gists{/gist_id}","starred_url":"https://api.github.com/users/cmb69/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmb69/subscriptions","organizations_url":"https://api.github.com/users/cmb69/orgs","repos_url":"https://api.github.com/users/cmb69/repos","events_url":"https://api.github.com/users/cmb69/events{/privacy}","received_events_url":"https://api.github.com/users/cmb69/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-08-14T17:34:05Z","updated_at":"2016-08-14T23:06:23Z","closed_at":null,"body":"Even though both formats are considered as being obsolete, their structure should be documented (if only for historic purposes). I've started documentation of the GD2 image format (mainly from reading the source code, and doing a few tests). This is what I have so far:\r\n\r\n\t* Structure of a GD2 image file:\r\n\t*  - file header\r\n\t*  - color header (either truecolor or palette)\r\n\t*  - chunks of image data (chunk-row-wise, top to bottom, left to right)\r\n\t*\r\n\t* All numbers are stored in big-endian format.\r\n\t*\r\n\t* File header structure:\r\n\t*  signature     - 4 bytes (always \"gd2\\0\")\r\n\t*  version       - 1 word (e.g. \"\\0\\002\")\r\n\t*  width         - 1 word\r\n\t*  height        - 1 word\r\n\t*  chunk_size    - 1 word\r\n\t*  format        - 1 word\r\n\t*  x_chunk_count - 1 word\r\n\t*  y_chunk_count - 1 word\r\n\t*\r\n\t* Recognized formats:\r\n\t*  1 - raw palette image data\r\n\t*  2 - compressed palette image data\r\n\t*  3 - raw truecolor image data\r\n\t*  4 - compressed truecolor image data\r\n\t*\r\n\t* Truecolor image color header:\r\n\t*  truecolor   - 1 byte (always \"\\001\")\r\n\t*  transparent - 1 dword (ARGB color)\r\n\t*\r\n\t* Palette image color header:\r\n\t*  truecolor   - 1 byte (always \"\\0\")\r\n\t*  count       - 1 word (the number of used palette colors)\r\n\t*  transparent - 1 dword (ARGB color)\r\n\t*  palette     - 256 dwords (RGBA colors)\r\n\t*\r\n\t* Chunk structure:\r\n\t*  Sequential pixel data of a rectangular area (chunk_size x chunk_size),\r\n\t*  row-wise from top to bottom, left to right:\r\n\t*  - 1 byte per pixel for palette images\r\n\t*  - 1 dword (ARGB) per pixel for truecolor images\r\n\t*\r\n\t*  Depending on format, the chunk may be ZLIB compressed.\r\n\r\nThere seems to be a glitch (perhaps a one-off bug): writing an image with 256x256 pixels and the default chunk size of 128 outputs 3x3 chunks.\r\n\r\n@kosinix I hope this is helpful. Please report back any mistakes or what could be improved."},"comment":{"url":"https://api.github.com/repos/libgd/libgd/issues/comments/239703468","html_url":"https://github.com/libgd/libgd/issues/288#issuecomment-239703468","issue_url":"https://api.github.com/repos/libgd/libgd/issues/288","id":239703468,"user":{"login":"cmb69","id":2306138,"avatar_url":"https://avatars.githubusercontent.com/u/2306138?v=3","gravatar_id":"","url":"https://api.github.com/users/cmb69","html_url":"https://github.com/cmb69","followers_url":"https://api.github.com/users/cmb69/followers","following_url":"https://api.github.com/users/cmb69/following{/other_user}","gists_url":"https://api.github.com/users/cmb69/gists{/gist_id}","starred_url":"https://api.github.com/users/cmb69/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmb69/subscriptions","organizations_url":"https://api.github.com/users/cmb69/orgs","repos_url":"https://api.github.com/users/cmb69/repos","events_url":"https://api.github.com/users/cmb69/events{/privacy}","received_events_url":"https://api.github.com/users/cmb69/received_events","type":"User","site_admin":false},"created_at":"2016-08-14T23:06:22Z","updated_at":"2016-08-14T23:06:22Z","body":"> This info is gold! One cant find anything on the web about the GD format.\r\n\r\nFirstly, GD and GD2 are image formats invented by libgd, so we're the ones who have to document them. Secondly, I presume that nobody else implemented GD/GD2 support. GD is hardly more than a raw data format (without even RLE); GD2 might allow for better compression than RLE enabled formats (such as TGA and BMP), but it lacks any synchronization and integrity checks.\r\n\r\n> Will keep you guys posted if I find anything.\r\n\r\nYes, please! :-)\r\n\r\nBTW: for your purpose to export/import image data, you're most likely better off with `image(createfrom)gd()` than `image(createfrom)gd2()`. The former contains the image data in row-major without any chunking. That's quite close to your suggestion in #285. Using `pack()`/`unpack()` might even deliver rather good performance with PHP.\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"cmb69"}}