Commit Graph

64 Commits

Author SHA1 Message Date
Andreas Kling
7141319a7c LibGfx: Remove DDS image format support
This format is not supported by other browsers.
2024-06-17 21:57:35 +02:00
Andreas Kling
4b4254c3d0 LibGfx: Remove QOI image format support
This format is not supported by other browsers.
2024-06-17 21:57:35 +02:00
Nico Weber
0c935f8f42 LibGfx/JPEG2000: Support reading raw jpeg2000 codestreams
Most JPEG2000 files put the codestream in an ISOBMFF box structure
(which is useful for including metadata that's bigger than the
~65k marker segment data limit, such as large ICC profiles), but
some files just store the codestream directly, for example
https://sembiance.com/fileFormatSamples/image/jpeg2000/balloon.j2c

See https://www.iana.org/assignments/media-types/image/j2c for the
mime type.

The main motivation is to be able to use the test data in J.10 in
the spec as a test case.
2024-04-19 12:42:34 -04:00
Nico Weber
f2e381ae19 LibCore: Add ".jpf" as a JPEG2000 extension
This is what Photoshop uses for JPEG2000 outputs.
2024-04-19 12:42:34 -04:00
Nico Weber
2467374ea9 LibCore: Add comment with link to mime registry to MimeData.cpp 2024-04-19 12:42:34 -04:00
Aliaksandr Kalenik
fea58a4160 LibCore: Support xml in guess_mime_type_based_on_filename() 2024-04-18 08:10:05 +00:00
Nico Weber
1ab28276f6 LibGfx: Add the start of a JPEG2000 loader
JPEG2000 is the last image format used in PDF filters that we
don't have a loader for. Let's change that.

This adds all the scaffolding, but no actual implementation yet.
2024-03-25 20:35:00 +01:00
Shannon Booth
e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00
Timothy Flynn
1f44c9468a LibCore: Replace MIME type description lookup with a more generic method
Rather than adding a bunch of `get_*_from_mime_type` functions, add just
one to get the Core::MimeType instance. We will need multiple fields at
once in Browser.
2024-03-16 08:42:33 +01:00
Nico Weber
58838db445 LibGfx: Add the start of a JBIG2 loader
JBIG2 is infamous for two things:

1. It's used in xerox scanners were it falsifies scanned numbers:

https://www.dkriesel.com/en/blog/2013/0802_xerox-workcentres_are_switching_written_numbers_when_scanning

2. It was allegedly used in an iOS zero day, in a very cool way:

https://googleprojectzero.blogspot.com/2021/12/a-deep-dive-into-nso-zero-click.html

Needless to say, we need support for it in Serenity. (...because it's
used in PDF files.)

This adds all the scaffolding, but no actual implementation yet.

It's enough for `file` to print the mime type of .jb2 files, but `image`
can't do anything with the files yet.
2024-03-09 16:01:22 +01:00
Andrew Kaster
e09bfc1a8c LibCore: Recognize .mjs as a common extension for application/javascript 2024-03-06 07:19:10 +01:00
Nico Weber
187862ebe0 LibGfx: Add a .pam loader
.pam is a "portrable arbitrarymap" as documented at
https://netpbm.sourceforge.net/doc/pam.html

It's very similar to .pbm, .pgm, and .ppm, so this uses the
PortableImageMapLoader framework. The header is slightly different,
so this has a custom header parsing function.

Also, .pam only exixts in binary form, so the ascii form support
becomes optional.
2024-01-26 07:36:53 +01:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Nicolas Ramz
cd6c7f3fc4 LibGfx/ILBMLoader: Add support for PC DeluxePaint files 2023-12-13 10:39:13 +00:00
Karol Kosek
9ce2682ce6 Userland: Port lists of mime types to String 2023-09-29 14:40:21 +01:00
Karol Kosek
2f35348104 Userland: Store MIME keys as String in Core::MimeData 2023-09-29 14:40:21 +01:00
Alexander Bosu-Kellett
13d1c37ea0 LibCore: Recognize .xht as an HTML document
This allows opening the WPT .xht files directly with ladybird.
2023-09-03 12:33:34 +02:00
Nicolas Ramz
fda5590313 LibGfx/ILBM: Add an IFF-ILBM decoder :)
IFF was a generic container fileformat that was popular on the Amiga
since it was the only file format supported by Deluxe Paint.

ILBM is an image format popular in the late eighties/nineties
that uses the IFF container.

This is a very first version of the decoder that only supports
(byterun) compressed files with bpp <= 8.

Only the minimal chunks are decoded: CMAP, BODY, BMHD.

I am planning to add support for the following variants:

- EHB (32 colours + lighter 32 colours)
- HAM6 / HAM8 (special mode that allowed to display the whole Amiga
4096 colours / 262 144 colours palette)
- TrueColor (24bit)

Things that could be fun to do:

- Still images could be animated using color cycle information
2023-08-15 18:36:11 +01:00
Lucas CHOLLET
475f1b6083 LibCore+LibGfx+LibGUI: Consider JPEG XL files as images
This includes registering the mime type and adding it to both the list
of supported image format and the filter for images type in LibGUI.
2023-07-21 10:47:34 -06:00
Sam Atkins
9f5e105958 LibCore: Add mime types for font files 2023-07-20 08:02:12 +01:00
Lucas CHOLLET
ce4b09dfd1 LibGfx: Register the mime type image/x-icon 2023-07-17 20:17:08 +01:00
Lucas CHOLLET
545fdc849f LibCore: Register the image/vnd.ms-dds mime type 2023-07-17 06:44:37 +01:00
Lucas CHOLLET
15bd708cfd file: Use the mime-type description provided by LibCore
This allows us to get rid of another mime-type list in the codebase.

To do so, the `get_description_from_mime_type` function is introduced in
this patch.
2023-07-14 17:33:06 +01:00
Lucas CHOLLET
c543a13835 LibCore: Share the mime-type list between the two detection methods
We used to have two separate lists for mime-type detection, one for
detection based on the file extension, and the other one for detection
based on byte sniffing.

This list also contains a general description that will be of use in
`file.cpp`.

To create this list, I had to fill in some gaps as the two lists started
to diverge.
2023-07-14 17:33:06 +01:00
Valtteri Koskivuori
5615ea5386 LibCore: Replace non-breaking hyphens with regular ones in MimeData
These three lines were added in commits 41d5531, 0f7a651 and 97aca8f all
the way back in June 2020, and went unnoticed until Lucas pointed this
out during my refactoring.
2023-07-11 17:48:57 +01:00
Valtteri Koskivuori
ff83b909f0 LibCore: Sort and tidy up filename mime guess function
These too should be sorted alphabetically, as evidenced by the fact that
text/markdown was in there twice before this change. :^)
Also broke out tables of sufffixes and basenames we consider plaintext,
and sorted those alphabetically as well.
2023-07-11 17:48:57 +01:00
Valtteri Koskivuori
21473ea7f1 LibCore: Improve mime type enumeration sorting
It makes far more sense to sort by the standard mime type strings,
rather than the ad-hoc variable names associated with each enumeration.
This way, the sort looks nicer, and also matches the corresponding
description enumerations in the file utility.
2023-07-11 17:48:57 +01:00
MacDue
ee09ecaf42 Userland: Register MIME type/extension for .tvg
These both come from the specification.
2023-07-03 23:54:51 +02:00
Timothy Flynn
13e1f61a81 LibCore: Support audio file extensions when determining MIME type
Similar to commit bcfa4a3, this enables navigating to a file:// URL in
Ladybird with audio file extensions.

The file extensions used here were taken from
https://docs.fileformat.com/audio/ (except QOA, which isn't listed).
2023-06-19 17:42:55 +02:00
Valtteri Koskivuori
e56098f734 LibCore+Userland: Remove uses of DeprecatedString in file utility
Mainly replacing DeprecatedString with StringView, since the actual mime
type and description texts are just static strings anyway.
2023-06-14 11:18:22 -04:00
Timothy Flynn
bcfa4a34a1 LibCore: Support the WebM file extension when determining MIME type
This enables, for example, navigating to a file:// URL in Ladybird with
a .webm file extension.
2023-05-16 12:48:39 +02:00
Lucas CHOLLET
50b5528746 LibCore+file: Factorize code to detect mime-type from bytes of a file
This is always nice to factorize code, but even better when it contains
magic numbers.
2023-04-27 07:29:49 +02:00
kleines Filmröllchen
9ff01723ba Userland: Use more common WAV MIME type
There is no official IANA MIME type for WAV (see
https://www.iana.org/assignments/media-types/media-types.xhtml#audio),
so this will always be subjective. While
https://www.rfc-editor.org/rfc/rfc2361 suggests audio/vnd.wave, we use
audio/wav since that seems to be most common across the internet.
2023-03-17 22:20:16 +00:00
kleines Filmröllchen
61bb9103c2 Base+Userland: Add support for QOA files everywhere
This adds MIME type sniffing,
`file` support,
LaunchServer support to open QOA in SoundPlayer,
and audio icons
2023-03-10 04:07:14 -07:00
Linus Groh
e76394d96c AK: Remove infallible version of StringBuilder::to_byte_buffer
Also drop the try_ prefix from the fallible function, as it is no longer
needed to distinguish the two.
2023-03-09 15:51:00 +00:00
Karol Baraniecki
f8e94f2862 LibCore: Use fallible versions of StringBuilder::append in MimeData 2023-03-09 12:59:57 +00:00
Karol Baraniecki
68d3f348d9 LibCore: Use fallible version of StringBuilder::to_byte_buffer
... in MimeData.

This function isn't used anywhere, not sure if it's useful?
2023-03-09 12:59:57 +00:00
Nico Weber
f7e152d049 LibGfx: Add scaffolding for a webp decoder
At the moment, this processes the RIFF chunk structure and extracts
the ICCP chunk, so that `icc` can now print ICC profiles embedded
in webp files. (And are image files really more than containers
of icc profiles?)

It doesn't even decode image dimensions yet.

The lossy format is a VP8 video frame. Once we get to that, we
might want to move all the image decoders into a new LibImageDecoders
that depends on both LibGfx and LibVideo. (Other newer image formats
like heic and av1f also use video frames for image data.)
2023-02-24 19:44:20 +01:00
Liav A
fedd18eb89 LibCore: Add MIME type string for TGA files 2023-01-20 15:13:31 +00:00
Liav A
e77b110541 LibCore: Return StringView from guess_mime_type_based_on_filename method 2023-01-20 15:13:31 +00:00
Nico Weber
e5988b4a0d LibCore: Teach MimeData about ICC file extension and contents
See https://www.color.org/profile_embedding.xalter and
https://www.iana.org/assignments/media-types/application/vnd.iccprofile
for mime type and extensions.

See LibGfx/ICCProfile.cpp, parse_file_signature() for the magic number.
2023-01-08 13:25:15 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
kleines Filmröllchen
f48651fccc LibCore: Add MIME sniffing for MP3 and WAV 2022-08-16 13:58:51 +01:00
kleines Filmröllchen
2c485a8e7b LibCore: The MIME type is 'audio/flac', not 'extra/flac' 2022-08-16 13:58:51 +01:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Karol Kosek
f47bcddb5b LibCore: Set mime type for .sheets files to application/x-sheets+json
This is our own format, used by Spreadsheet.
2022-05-22 03:08:53 +04:30
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Maciej
b172bf4f84 LibCore: Add text/css mime type
Firefox throws out css files with MIME type not being "text/css", so
let's add it to make attached CSS working on WebServer. :^)
2022-03-19 22:03:51 +01:00
Maciej
273b69f947 LibCore: Add some extensions that are text/plain
C++ source/header files, GML, IPC, CMake and various Serenity config
files.
2022-03-19 22:03:51 +01:00