Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support of netpbm files #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ysyrota
Copy link

@ysyrota ysyrota commented May 4, 2022

Added support of netpbm files (PAM, PFM, PBM, PGM, and PPM) and Regular Expression based detector.

@codecov-commenter
Copy link

Codecov Report

Merging #283 (c6a596b) into master (fe5b52f) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #283   +/-   ##
=======================================
  Coverage   94.96%   94.96%           
=======================================
  Files           3        3           
  Lines         159      159           
=======================================
  Hits          151      151           
  Misses          6        6           
  Partials        2        2           
Impacted Files Coverage Δ
tree.go 50.00% <ø> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Owner

@gabriel-vasile gabriel-vasile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally against regex but it is notorious for being slow.
As far as I understand the netpbm formats,

  • they all with Px, x being any digit between 1 and 7
  • followed by two or tree integers
  • in-between Px and each of the integer there can be any number of spaces or comments marked with #.

One problem with the current regex is that it fails for:

P2
# Created by GIMP version 2.10.30 PNM plug-in
6 # Another comment
10
255
255
255
...

I think it's worth doing a second implementation for the netpbm checks and comparing their performance. What we need for that is a function that parses the width, height numbers from the netpbm header.

Copy link
Owner

@gabriel-vasile gabriel-vasile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something similar with this function, but stripping away the things we don't need (ex: we don't need it to return comments). We also need to give credit to the author, if we end up using our own version of that function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants