aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/data/media
Commit message (Collapse)AuthorAgeFilesLines
* Fix Thumbnail404EntryPointTest::testStreamOldFile failures with gdAaron Schulz2024-11-251-0/+0
| | | | | | | | | | Scaling two very small and similar images down to a tiny size can result in the same png depending on whether gd or image magick is used. The tests should not depend on these config differences. Add some more wfDebug() statements to File::transform() methods. Change-Id: I441cbec1a949d0ed6df6e83c793063c5377f9654
* Extract XMP & Exif from WebP filesBrian Wolff2024-05-115-0/+0
| | | | | | | | | | | In addition to the webp spec, this also detects two non-standard conventions sometimes found in real files: Allowing a fourcc of "XMP\0" instead of the standard "XMP " and allowing the prefix "Exif\0\0" at the beginning of the EXIF chunk. Bug: T338341 Bug: T353981 Change-Id: I0ddc3322e1c2f4d4d7bb11732e05fd4ffb5eb692
* test: Add PHPUnit tests for BmpHandlerDoğu Abaris2024-02-083-0/+0
| | | | | | | | | Covered: - `testMustRender`: Confirmed handler's necessity to render the file. - `testGetThumbType`: Verified thumb type returned for BMP files. - `testGetSizeAndMetadata`: Tests with various BMP file sizes. Change-Id: Ib01914e1ab66ca10ff4e089a0fd591d0b544edf5
* SVGReader: Detect CSS animated SVGsDerk-Jan Hartman2023-11-051-0/+17
| | | | | | | | | | | | This does a string check on animated and @keyframe in style elements for SVGs. If there is a match it will treat this SVG as animated. While in theory this could be a false positive, without fulling parsing the CSS, the chances of that seem minor and there are no real negative consequences either. Bug: T332790 Change-Id: I4b8b0781e8f9135d9ab856f3ec06f5a76c66c9a8
* Make ExifRotationTest dramatically fasterthiemowmde2023-09-122-0/+0
| | | | | | | | | | | | | Down from about 1000ms to 200ms. By using much smaller images. The absolute size of the images is not relevant for this test. Only the ratio. There was nothing special about the "landscape-plain.jpg" image. But "portrait-rotated.jpg" was: It's technically stored in landscape, but marked with an EXIF tag for rotation. I used exiftool to copy the EXIF data to the smaller version, so it behaves the same as before. Change-Id: Ie977dfbceff02e4dfde38a5ef82e8ff81b4d6980
* SVG Language selector should default to page languageDerk-Jan Hartman2022-06-131-0/+4
| | | | | | | | Taking into account the pagelanguage should help take into account the language variant on image pages in languages that have variants. Bug: T310445 Change-Id: Ic821b2de66ed876e47c74ac21cedaad7a70a80fc
* Call ZipDirectoryReader from MimeAnalyzerTim Starling2022-05-033-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | Remove the special case GIFAR vulnerability check from UploadBase. I put it there because the GIFAR vulnerability was so severe that we needed to check for it even if $wgVerifyMimeType was false. Now that support for Java applets has been dropped from browsers, the vulnerability is not so severe and we can wind back the paranoia. Add a ZipDirectoryReader invocation to MimeAnalyzer, to replace some terrible regex hacks. This allows MimeAnalyzer to detect docx files saved by LibreOffice (T291750). This is also the new place for the GIFAR check. Add application/java to $wgMimeTypeExclusions so that JAR uploads are rejected. Since ZipDirectoryReader cannot look inside the contents of files in the package, it can't detect the subtype of Open Document files. Use the file extension instead, like what we do for Microsoft OPC files. Remove public method detectZipType -- no callers in code search. Bug: T291750 Change-Id: Iff1611c7adda9c0f0ed31593bad6dfffc9c9a086
* Ignore invalid chunks in PNG files, instead of aborting metadata extractionTim Starling2021-07-131-0/+0
| | | | | | | | | | | | * Factor out file read errors and unexpected EOF errors. * For errors relating to chunk content, instead of throwing an exception which is silently discarded, just log an error and continue to the next chunk. This allows the dimensions to be extracted even if other metadata is mangled. * As an additional sanity check, verify the CRC of each chunk. Bug: T286273 Change-Id: I11d0186496324e0bb1bb0a143f438e0368a8e902
* Merge "Fix replacement of control chars in DJVU text output"jenkins-bot2021-03-291-0/+0
|\
| * Fix replacement of control chars in DJVU text outputInductiveload2021-03-291-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | The control characters are presented as text, not actual control characters, so the regexes to replace them are incorrect. Added a column and para to the Djvu text on the first page of the test LoremIpsum.djvu file Bug: T230415 Change-Id: I4970bc30b3935ce4da062ee7ff687aa667027a00
* | JPEG2000 MIME fixesDerk-Jan Hartman2021-03-154-0/+0
|/ | | | | | | | | | - jp2 is the preferred file extension - add mime aliases - add jpg/jpx (jpeg2000 part 2) - add magic byte detection for both Bug: T161934 Change-Id: I00f81d9c31bf53a3b950e8a1d2bf2684c3998745
* Fix XMP parser errors due to trailing nullcharDerk-Jan Hartman2019-09-111-0/+0
| | | | | | | | JPEG files can have trailing \0 chars at the end of the XMP value. Use trim() to remove these from the string value. Bug: T118799 Change-Id: Id4ab223ef432e5d2c0dd3b4e332320db02422700
* MimeAnalyzer: fix ZIP parsing failureTim Starling2019-07-254-0/+0
| | | | | | | | | | | | | | | | | | unpack() actually returns an array with indexes starting from 1, not zero, so unpack(...)[0] gives a notice and always returns null. It is lucky that ZIPs normally have zero-length comments, so this would have had little impact on file type detection aside from log spam. Also, add a check to make sure the unpack() will not read beyond the end of the file. Without this, unpack() could generate a warning. The bug was introduced by me in f12db3804882272794b. Add tests. The test files were generated by appending an EOCDR signature and some extra bytes to 1bit-png.png. Bug: T223728 Change-Id: I6fab63102d1d8eea92cdcce5ab6d1eb747a0a890
* Display translatable images in wiki language on image pagesMax Semenik2019-02-041-0/+10
| | | | | | | | | We currently show SVGs in default languages unless overridden with lang=... URL parameter (and we have UI for setting it). This change makes it display thumbnails in wiki language, if translation is available. Bug: T210814 Change-Id: Ieb0b5e9e27f45b71ef119bb3c1d3f2cd4d7100e5
* Better detection for old MS Office filesTim Starling2019-01-231-0/+0
| | | | | | | | | | | | * Introduce MSCompoundFileReader, which reads the CFB directory and detects the file type from well-known names in the root directory * Do not detect a ZIP file if the EOCDR is not at the end. Other containers, especially CFB files, may contain ZIP files embedded within them in the last 64KB, but this is not a security concern unless the EOCDR is exactly at the end of the file. Bug: T40432 Change-Id: Id5b1a258ccf3c3c8951e32f6b7a5b1bafe941082
* SVG: Allow , as separator in viewBox attribute valueDerk-Jan Hartman2018-08-111-0/+3
| | | | | | | | | The viewBox attribute of the <svg> element allows both whitespace and commas to be used as field separators. https://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute Bug: T194192 Change-Id: Iae9be3e4fad3a8ffa411d7a76eee2f20cc39b718
* Adjust tests for JPEG segmentation fixBrion Vibber2018-02-232-0/+0
| | | | | | | Added a second test case truncated in a different place, and added some clarifying comments. Change-Id: I7b8e5296a203264b7e7e428f82c8c948242a1272
* Fix infinite loop in JpegMetadataExtractorBrion Vibber2018-02-211-0/+0
| | | | | | | | | | | | | | One of the skip-over loops was missing an feof() check and could cause infinite loops. Includes test file created by truncating a tiny tiny .jpeg at the right place... With the fix, it doesn't loop but dies on an exception, which is good! Bug: T184048 Change-Id: Ica13d6b68c3c12f7ce414edd081bf0886714e465
* Replace HTTP by HTTPS in docsFomafix2017-10-151-5/+5
| | | | Change-Id: I311c40f8aa90f308a0817f4c3ce1b9449b1f5ca7
* MimeAnalyzer: Add testcases for mp3 detectionDerk-Jan Hartman2017-06-084-0/+0
| | | | | | | This is a follow-up to change Ie1a63aa Bug: T115170 Change-Id: Iab5e19e1dd26b0d88c72ad7253cd11e865c5e008
* Merge "Embed TinyRGB color profile when JPG EXIF Color Space = sRGB but no ↵jenkins-bot2017-05-044-0/+0
|\ | | | | | | profile embedded"
| * Embed TinyRGB color profile when JPG EXIF Color Space = sRGB but no profile ↵Matthias Mullie2016-11-154-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | embedded Existing srgb.jpg & tinyrgb.jpg have been replaced to be able to easily compare a "fixed" missingprofile.jpg to tinyrgb.jpg. With the existing files, when the tinyrgb profile was added to missingprofile.jpg, it would end up basically the same as tinyrgb.jpg, except that not all the exif data would be in the exact same order. I've rebuilt srgb.jpg & tinyrgb.jpg by first removing their profile (which is what missingprofile.jpg is), and then copying it over again: exiftool -tagsfromfile srgb.jpg -ICC_Profile new_srgb.jpg Meanwhile also moved the profile-swapping code to JpegHandler, as it was jpeg-specific. Bug: T134498 Change-Id: I722dd6f66f6007182ad9a215e5eb382776983c05
* | Add test case for Opus file checkBrion Vibber2017-01-171-0/+0
|/ | | | | | | | | Test case for Opus file check so we don't regress! Confirms the fix for T151352 that Opus files return type 'audio' and not 'multimedia'. Bug: T151352 Change-Id: Ib868793d90b60609ccec25726e6fbaa28bffebaf
* Enable 4:2:0 chroma subsampling for JPEG thumbnailsBrion Vibber2016-04-272-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add $wgJpegPixelFormat, default to 'yuv420' * Implemented for ImageMagick via CLI and extension * Currently ignored for other scaler backends * Added test case to run when using ImageMagick 4:2:0 subsampling can save an average of 17% bandwidth over 4:4:4 subsampling, at the cost of some artifacting at sharp red or blue edges. This is usually not noticeable in photographic images. To restore the previous behavior, set to false: $wgJpegPixelFormat = false; which will maintain the original file's pixel subsampling settings in the thumbnail. Can set explicitly to one of: 'yuv444' - never subsample 'yuv422' - subsample 2x horizontally, not vert 'yuv420' - subsample 2x in both dimensions Bug: T129128 Change-Id: Ib9cb36c3a7e6a69d66c11150ef4a1d02dbac2df5
* Basic support for WebPbtongminh2015-06-263-0/+0
| | | | | | | | | Adds basic image size detection for WebP and support in the MediaHandler. Currently renders WebP files as PNGs, because that handles transparency. Bug: T50519 Change-Id: I3c00653a8a034efc3f6b60fe62b7ac2e5391f921
* TinyRGB support for JPG thumbnailsGilles Dubuc2015-06-223-0/+0
| | | | | | | | | | | | | | | | | TinyRGB is an ICC profile released by Facebook under CC0. It is designed to be fully compatible with sRGB. It offers the vast advantages of being much smaller than sRGB, as well as being free as in freedom (the sRGB profile found in the majority of JPGs is copyrighted). This change aims to provide the ability to swap sRGB for TinyRGB at the time thumbnails are generated. JPGs that use another ICC profile than sRGB or no profile at all are unaffected. Bug: T100976 Change-Id: I2ae35ddad4e8a82db8b9541974367dc76c884e7a
* Change to unix eol styleReedy2014-12-242-957/+957
| | | | Change-Id: I0a5f91ccdbeed28ce41614ba8721944de876056d
* Add unit tests for ffmpeg2theora ogg recognition bugBrian Wolff2014-07-042-0/+4
| | | | | Change-Id: I2e6944ccff3882b9f9ee1ac5ab6f5fea1de9d353 Follow-up: 629169ce9bd7
* Fix misnamed SVGHandler::canAnimateThumb()Brian Wolff2014-06-103-0/+64
| | | | | | | | | | | | Caused the animation warning to not be present on image description pages Also add unit tests. Since I'm adding an animated svg file for this unit test, also add a metadata extraction test for animated svgs, since we're missing one. Change-Id: Id03e1a0e1c151d3c575a695a42c54b709187d10a follow-up: 876128f8c9f0ce6a8424336f
* Revert "Use square bounding boxes for default-sized thumbnails"Tim Starling2014-06-021-0/+0
| | | | | | | | Reverting for further discussion, due to community complaints at https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_%28technical%29&oldid=611154541#Infobox_Image This reverts commit 7db55341791cb44ca599b84bea707b05de2f227d. Change-Id: Ieea6224b2a295b5d65bbd486e30cf0573376c7e9
* Use square bounding boxes for default-sized thumbnailsC. Scott Ananian2014-05-211-0/+0
| | | | | | | | | | | | | | | | | Thumbnails for portrait-orientation images have always been "too big", especially when displayed in a gallery. The 'upright' option did not completely fix the issue. Using a square bounding box for thumbnails (and 'framed' images) without an explicit size specifiction provides a better default appearance. This also provides a clean syntax for content authored using Parsoid/Visual Editor, which prefers square bounding boxes. See: https://www.mediawiki.org/wiki/Requests_for_comment/Square_bounding_boxes Bug: 63903 Change-Id: I665d8945843d3b5437a74e376b63c44965590116
* Use correct Creative Commons license abbreviationSiebrand Mazeland2014-03-241-2/+2
| | | | Change-Id: I7df989de9dca2ee056030ff6f5830d5f0124185e
* Merge "tests: beginning of tests for DjVu files"jenkins-bot2013-12-101-0/+0
|\
| * tests: beginning of tests for DjVu filesTpt2013-12-101-0/+0
| | | | | | | | Change-Id: I453b2b1a1c4999150a570e22170a9c630c2ef265
* | Extract list of languages svg is translated into.Brian Wolff2013-12-062-0/+19
|/ | | | | | | | | | | | | | | | | | | SVG files support having different renderings based on language. We support changing the rendering language, but we offer no discoverability of what languages are available. Long term Jarry's TranslateSVG will hopefully be used and have all the associated awesomeness. In the mean time, we should probably have some indication on the image page what languages are available for the SVG. This is step 1 (extract the language). I expect to follow this up with a commit adding some sort of simple selector on the image page. As an aside, it should be noted, this only detects languages if its in the first $wgSVGMetadataCutoff (256 kb). This is a compromise to avoid OOM on huge SVG files. Change-Id: I2a462270fe63eb3e3023419eddc8b06f5a617ab5
* Add an interface for getting "standard" file metadata.Brian Wolff2013-10-292-0/+907
| | | | | | | | | | | | | | Currently file metadata is handler dependant. However they usually end up extracting the same type of data (author, date, etc) plus one or two handler specific things. This adds a handler independent interface for getting metadata that is likely to be common for all types of file (At the moment, this is the exif/iptc/xmp information) This commit used to also contain stuff adding parser functions, which is now split to its own commit. This commit is needed by a bunch of other commits, in particular I0d957891e0. Change-Id: I43d9252f69dc5b8ba0b848cf40aa1b97329c85ae
* (sort of bug 32410) Fix EXIF GPSAltitude calculation when below sea level.Brian Wolff2012-08-231-0/+0
| | | | | | | | | | | | | | | | | | | | | | | In EXIF, GPSAltitude is stored as a fraction string like "1/2". For values below sea level we were negating this value, in order to represent the sign and the magnitude in the same value. However, I forgot to convert that to an integer before negating it. PHP was nice enough to do a best effort conversion of the string to an integer. This resulted in altitudes below sea level being taken as just the numerator of the altitude, which gives results that can be significantly off. Also add unit tests for the GPS related image metadata stuff. Change the existing GPS test to use a fractional altitude (Since this issue isn't appearent if the denominator is 1). Add tests for XMP as well, since XMP had same issue, and has to do same processing as EXIF stuff does. In some future time, may want to consider just converting all exif rational values to real numbers during the extraction process for generally better sanity. Patchset 2: rebase Change-Id: I49032b52a4c840b28e667a6a2b8ae23c508df247
* Make sure that if we fail to read the App13 (iptc) block of a JPG file, that ↵Brian Wolff2012-01-051-0/+0
| | | | | | | that doesn't block other metadata from being read. Also makes sure if more then one app13 block is in the file, they are all read, not just the last one that appears in the file (This required some changes to tests since before the intermediate value was just one value, now its an array of all such blocks) Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/108183
* add basic XCF pictures for testing purposeAntoine Musso2012-01-053-0/+0
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/108149
* svn property on .svg file (follow r107940)Antoine Musso2012-01-041-150/+150
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/108000
* PHPUnit test case for bug 31719 (followup r107793)Brion Vibber2012-01-031-0/+150
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/107940
* (follow-up r100575 / r99477) unit-tests for jpegMetadataExtractor dealing ↵Brian Wolff2011-10-243-1/+2
| | | | | | | with padding bytes. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/100576
* (follow-up r86169) Moar unit-tests!! (sorry for uttetly huge commit)Brian Wolff2011-08-2114-1/+39
| | | | | | | This should be my last commit of unit tests for the media metadata stuff (hopefully). Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/95163
* follow-up r86169: unit tests for extraction of JPEG comment (COM) segments.Brian Wolff2011-08-185-1/+2
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94867
* Move the image files used in the media tests from includes/media to ↵Brian Wolff2011-08-1718-0/+407
data/media as the includes/media was starting to get crowded with supporting image files. This changes the following things *Moves the media files to a different directory *Changes the references to the files to reference there new locations 2 semi-unrelated changes *Modify the README file that was basically giving credit for the images where due to explain what the images are for. *set svn:mime-type to image/svg+xml for the svg files. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94848