Comments (3)
@ronaldtse
I am not sure I understand this requirement. PNG is coding standard. The errors that pngcheck finds are coding errors. If we run png file through decoder there is nothing to check. Decoder will either fail ot create 'flat' (raw) image that is not png-encoded
from pngcheck-ruby.
I guess what I was trying to ask for is a way to use pngcheck without considering the file system (with the PNG file loaded into memory). I can see how it doesn’t work as per the example.
Given an invalid PNG, a PNG library will either:
- fail to load the image gracefully
- crash
- Interpret the image in an erroneous way
The reason why we need pngcheck is in Metanorma — there have been users who generate the document, and in some outputs the PNG works but not in others (eg images in Word and HTML/browsers, or different platforms, use different PNG libraries). The users blame our software for these problems and we don’t want that to happen. The solution is when Metanorma gets these image files, it must err out of these images so the authors (whoever is using Metanorma) needs to fix them.
As long as we have a cross-platform way to ensure these PNG images work is sufficient. I just don’t want Metanorma to deal with file system path normalization etc so much.
from pngcheck-ruby.
Then it looks like you are asking for the following:
require 'png'
encoded = IO.binread("test.png")
begin
PngCheck.check(encoded)
dec = PNG::Decoder.new(:color_type => :BGR)
raw = dec << encoded
rescue PngCheck::CorruptPngError
# say something
end
from pngcheck-ruby.
Related Issues (16)
- Implement pngcheck Ruby gem HOT 3
- Check if `pngcheck` gem works and provide documentation in README HOT 1
- Implement pngcheck `check_file` method
- Create pre-compiled pngcheck binaries for easy gem install across platforms HOT 1
- Image generated by PlantUML via Metanorma identified as corrupt HOT 4
- pngcheck is breaking on selected plantuml output HOT 5
- If content is empty, don't fail with a scary message HOT 2
- macOS Screenshot application generates invalid PNG files HOT 7
- Skip shared library check if file command is not available
- Package `pngcheck` source code during gem build process
- FYI: pngcheck repo
- Publish linux-gnu, linux-musl native extensions to rubygems HOT 1
- `pngcheck` gem should not provide the `rspec` executable
- Build zlib locally during cross-compilation
- Change platform for native extension from (x86_64|aarch64)-linux to (x86_64|aarch64)-linux-gnu HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pngcheck-ruby.