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

Add support for SVG #724

Closed
wants to merge 1 commit into from

Conversation

Shashee99
Copy link

@Shashee99 Shashee99 commented Jan 26, 2025

This PR adds support for detecting the SVG file format. Below are the details:

  • File format: SVG (Scalable Vector Graphics)
  • MIME type: image/svg+xml
  • Detection confidence: detectConfident() — SVG files are identified with high certainty based on their distinct structure and signature.

Changes made:

  1. Fixture file: Added fixture.svg to the fixtures directory.
  2. Supported file types:
    • Added .svg extension to the extensions array in supported.js.
    • Added MIME type image/svg+xml to the types array in supported.js.
  3. Detection logic: Added the logic for detecting SVG files in the core.js file.
  4. Confidence category: Since the structure of SVG files is unique and easy to detect, this detection is classified under detectConfident().
  5. Documentation:
    • Updated the "Supported file types" section of the README to include SVG in alphabetical order.
    • Added .svg extension to the keywords array in the package.json.

References:

@sindresorhus
Copy link
Owner

From the top of the readme:

This package is for detecting binary-based file formats, not text-based formats like .txt, .csv, .svg, etc.

There are also many things wrong with this pull request, and I also suspect it's AI generated based on the pull request description.

@Shashee99 Shashee99 deleted the add-support-for-svg branch January 26, 2025 15:57
@Shashee99
Copy link
Author

Thank you for your feedback! I understand now that this package is focused on detecting binary-based file formats. However, I added support for SVG because it is a common and well-defined format, and it includes a structured text format that is easy to detect programmatically (via its unique XML-based signature). While SVG is technically text-based, it’s used widely in many image processing workflows, which is why I thought it could be a useful addition.

@Borewit
Copy link
Collaborator

Borewit commented Jan 26, 2025

I wrote a file-type plugin for XML file types, which does detect SVG as well: @file-type/xml, which would be nice to mention somewhere in the README, as proposed in PR #708.

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