Commit graph

153 commits

Author SHA1 Message Date
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Brad Jorsch
645266fe3e Fix MediaTransformError message handling
Give access to the raw Message instead of only to the HTML or text in
the RequestContext language.

Pass Message objects instead of strings from calling ->text() as the
parameters of Messages so if the outer Message's language is changed
things get parsed sensibly.

Change-Id: Ibd6c1217b6fed839c888b66e02900f8e21ed3e6b
2016-11-30 10:56:03 -05:00
Max Semenik
f0c8cbc6d9 Remove a few unused variables
Change-Id: Ibfc4c6cbbc08b5917f1a84d86d2d4a0855e371a1
2016-09-26 17:03:32 -07:00
Brion Vibber
a30bc4f7e0 Enable 4:2:0 chroma subsampling for JPEG thumbnails
* 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
2016-04-27 15:36:18 -07:00
addshore
842fd77e79 Remove unused global $wgMaxInterlacingAreas in Bitmap.php
Change-Id: I3b1a0d65be4327a5e0a47934a470c2573e315fea
2016-04-03 11:05:03 +03:00
Ricordisamoa
7972c460ed Add missing 'public' keywords to some MediaHandler methods
* getParamMap
* validateParam
* makeParamString
* parseParamString
* canRender
* mustRender
* isMultiPage

Change-Id: I0c00a61abf9be400dca5407370ca2c232d57ae17
2016-02-24 00:47:02 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Bartosz Dziewoński
2aba862486 BitmapHandler: Implement validateParam()
Follow-up to 695a93dd33.

Bug: T125804
Change-Id: Ifde40bb5d7c60dd19727f5e47041a6e676f7e3c8
2016-02-04 17:01:44 +01:00
Andrew H
695a93dd33 Add support for image interlacing of Bitmap type images
Add 'interlace' parameter and $wgMaxInterlacingSizes global.

Bug: T120032
Change-Id: I40dee74060026513f1c2be8c22dfe41a0b4a18df
2016-01-16 05:48:27 +00:00
Darian Anthony Patrick
fd0ca2f3a0 Avoid exposure of local path in PNG thumbnails
Bug: T108616
Change-Id: I952068d2d175d71f86dec0dbb92af5a122c05a49
2015-10-16 14:51:09 -07:00
Siebrand Mazeland
016d012dbf Fix PHPCS warnings in /includes/media/
Change-Id: I9b551dd7b9f4e8a11f86a1acf2c7241f02d85515
2015-09-28 13:50:44 +02:00
Amir E. Aharoni
7a2d08ee72 Fix LineLength in includes/media
Bug: T102614
Change-Id: Id46d9040e264cd2af1174938dde58ea7d9c0bb5e
2015-09-26 20:01:29 +03:00
jeroendedauw
f7c5226952 Remove not needed global imports in BitmapHandler
Change-Id: I5b3a666157a47492c28129c1b2fa52a4422c10d5
2015-09-07 21:48:19 +02:00
btongminh
9c8f333eb8 Basic support for WebP
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
2015-06-26 19:38:38 +00:00
Gilles Dubuc
584a239318 TinyRGB support for JPG thumbnails
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
2015-06-22 16:17:54 +00:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
Aaron Schulz
4ff8136807 Removed remaining profile calls
Change-Id: I31c81c78715048004fc8fca0f27d09c1fa71c118
2015-01-08 02:49:33 -08:00
Ricordisamoa
fc5fd5c37a Typo fixes and non-code tweaks
Skipped replacements:
* prefered → preferred
* prolly → probably

Skipped files:
* resources/lib/jquery.ui/jquery.ui.mouse.js
* resources/lib/jquery/jquery.form.js

Change-Id: Ib7923f362ddfca1b892bf5d601785d6b5aa5d44c
2014-12-12 18:31:15 +00:00
umherirrender
489d793882 Fixed spacing
- Added/removed spaces around parenthesis
- Added newline in empty blocks
- Added space after switch/foreach/function
- Use tabs at begin of line
- Add newline at end of file

Change-Id: I244cdb2c333489e1020931bf4ac5266a87439f0d
2014-12-05 22:28:07 +01:00
Gilles Dubuc
27f6596a86 Don't re-apply EXIF rotation to chained thumbnails
Change-Id: I2f0674e4aea508ad7e00b7742a9d47bd0659e399
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/600
Bug: 67525
Bug: 73352
2014-11-13 11:26:15 +01:00
Brian Wolff
757a70ae0a Split BitmapHandler into two classes.
BitmapHandler has a lot of generic-ish functionality that could
be re-usable by extension classes (Such as how it organizes
$scalerParams array, or various image magick escaping methods).
However it's combined with a lot of very format specific things,
such as the shell-out call to image magick.

Try to separate out the more generic stuff into
TransformationalImageHandler. In order to do this, I also made
canRotate, autoRotateEnabled, and getScalerType non-static. No
extensions in our repo appeared to be using these methods, and they
don't really make sense to be static (imo).

In particular, I think code duplication can be reduced in
PagedTiffHandler by extending this new class. See comments
on I1b9a77a4a56eeb65.

Change-Id: Id3a8b25a598942572cb5791a95e86054d7784961
2014-09-14 22:10:37 +00:00
umherirrender
4ee680a8b3 Fixed spacing
- Removed spaces after not operator (!)
- Removed spaces inside array index
- use tab as indent instead of spaces
- Add newline at end of file
- Removed spaces after casts

Change-Id: I9ba17c4385fcb43d38998d45f89cf42952bc791b
2014-07-24 11:53:04 +02:00
Brian Wolff
bceb8b6acf For xcf files, compose layers before scaling
Otherwise if some layers are a different size than the overall
image, the output will be distorted as all the layers will be
resized.

An example of such a file is the 2007 version of
[[File:Blason_Saint-Malo.xcf]] (Need a version of image magick
newer than production to see the issue).

Bug: 35622
Change-Id: Ibbe8645afc151b0e9b658f762497071d67be3836
2014-07-20 11:44:50 -03:00
jenkins-bot
b15bfd99a9 Merge "Generate thumbnails based on buckets" 2014-07-09 14:09:02 +00:00
Gilles Dubuc
7036e7b68d Generate thumbnails based on buckets
Instead of always generating thumbnails based on the original,
this adds the ability to generate thumbnails based on
references buckets. The buckets themselves have their
generation chained following the same process (smaller bucket
generated based on bigger bucket). In situations where no
suitable bucket is found, the original is used, like it used to.

This is entirely optional, as most non-WMF wikis would probably prefer
to keep generating all thumbnails based on originals.

The quality implications have been verified through a survey
aimed at Commons users and people actually preferred the chained version.
Presumably due to the multiple passes of sharpening which maintained
visual details better for small thumbnail sizes.

Change-Id: I285d56b2024c81365247338f85c1e0aa708cb21e
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/600
Bug: 67525
2014-07-08 20:03:38 +00:00
Brian Wolff
9dbc0cce8a Fix alpha transparency in XCF images
The -layers merge option flattens all layers on to a canvas
of whatever color -background is set to. However -background
was white for the PNG bKGD chunk. Set it to transparent just
for the -layers merge operation.

This works well on most recent image magick. Older image magick
explodes on my test image (I tested 6.6.0-4), so unclear if it
works there, but it certainly didn't make anything worse.
Wikimedia uses a version between the two that I tested so hopefully
this will make things better, and if it doesn't, it eventually will
when we update image magick.

Bug: 35622
Change-Id: I77601cdf005a64ae8ea7516cc846620431917863
2014-07-04 01:50:39 -03:00
Brian Wolff
24dcc22614 Workaround image magick issue with greyscale xcf files
IM doesn't seem to properly interpret greyscale xcf files
as being greyscale. Tell it to just take the red channel
in such a case.

Bug: 66323
Change-Id: I46302d43e1029d815be99f481f3942481becd74f
2014-06-19 21:06:23 -03:00
Yuri Astrakhan
a77032257f Allow mobile to reduce image quality
http://www.mediawiki.org/wiki/Requests_for_comment/Reducing_image_quality_for_mobile

Per above RFC, this patch implements the core changes required to
specify quality reduction of JPEG via URL. To test, make sure your
setup uses 404-based thumb generation. Vagrant supports it by adding
"multimedia" role:  $ vagrant add-role multimedia && vagrant provision
* Pick any thumbnail jpeg URL that exists on the test wiki, e.g.
  http://.../images/thumb/4/49/Img.jpg/400px-Img.jpg
* check that basic scaling works by altering 400
* add quality parameter qlow- right before px:
  http://.../images/thumb/4/49/Img.jpg/qlow-400px-Img.jpg

Change-Id: I930ea06be6d302ffc8832d12b251422a9f1b3e75
2014-05-09 16:39:54 -04:00
Reedy
e8ff01276c Remove undefined $env and TODO comment for it too
Change-Id: Ie69a68c8ff429ac79796890d1843cf2a2b9c32e8
2014-02-20 03:47:25 +00:00
Tim Starling
2d3ffcc316 SECURITY: Sanitize shell command args
Add validation and sanitization to several code paths.

Bug: 60339
Change-Id: Id124281d21ec730a2e0bbace843dd97194a712b4
2014-01-29 10:26:50 -08:00
Aaron Schulz
0177cb82cd Improved vague/incomplete $1 thumb.php error messages
Change-Id: I64d05e25f82242e92abbcbf20252fc17d5790d8b
2014-01-17 18:20:17 -08:00
Aaron Schulz
875a597e7f Move BitmapHandler::canRotate() call out of Setup.php
* This was wasting 5ms on every request hit on test wiki

Change-Id: Ie7a5aa27593ab8e0d52fb00218345d1789da61a1
2013-12-21 21:44:30 -08:00
Siebrand Mazeland
24a2060253 Some more formatting fixes for media classes
Based on Brian's review of https://gerrit.wikimedia.org/r/#/c/99344/

Change-Id: I35aea90da837d17bf8be5c29d22f5f0a3bcef145
2013-12-08 10:45:35 +01:00
Brian Wolff
2a4823b1d1 Include error code in error message when convert fails
This info is logged, but it makes it much easier to debug
things if the info is right there.

Change-Id: I3a331a19a13a932c6b7aefdd9885ad351f3f48e3
2013-12-07 21:40:26 -07:00
Siebrand Mazeland
37bc4ec3dd Update documentation for media related classes
Change-Id: I7a9c8d59f88c68dc3835cb8a18f22a77cd7890fc
2013-12-06 23:03:06 +01:00
Antoine Musso
96ddd951fb generalize BitmapHandler::logErrorForExternalProcess
BitmapHandler::logErrorForExternalProcess is a wrapper around
wfDebugLog( 'thumbnail' ). It got copy pasted from some other class at
one point.

This patch move the method up to general class MediaHandler and makes
other child class uses it.  The method will thus be available to
extensions such as TimedMediaHandler.

The reason I am doing that is that trim($err) generates a copy of $err
which causes a memory allocation fatal error whenever $err is larger
than the remaining memory allocatable.  The patch will let us fix the
bug by only altering one part of the code.

bug: 57985
Change-Id: I5657f07d6e2cca05d53f2a5c30ec23622c171343
2013-12-06 18:21:58 +01:00
Siebrand Mazeland
370101602c Break long lines in media related classes
Change-Id: I94653b4cde14f75180dae795d1fdaa1b073ec1d1
2013-12-05 12:33:18 +01:00
Siebrand Mazeland
c7dbaa0f58 Update formatting for media related classes
Change-Id: Iaa81af5b65a650222fa65bf8c368e4f1ec3ce9c0
2013-12-05 11:05:05 +01:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
Aaron Schulz
8d266860d6 Clarify thumbnail log failure entries when the local file copy failed
Change-Id: I8ed9a5ffc04b1abd2e7b2c055dfdfb2625e89fde
2013-11-08 20:52:12 +00:00
jenkins-bot
b328d69881 Merge "Move getRotation and getImageArea to the base class" 2013-09-30 17:15:15 +00:00
Brian Wolff
1aea0ce29e Move getRotation and getImageArea to the base class
This way we know we can always safely call getRotation on any image.

In particular, PagedTiffHandler doesn't extend BitmapHandler, and I
want to make VipsScaler work with PagedTiffHandler, and it calls
getRotation.

Change-Id: I63f2be2a6f31398918b8562e15343f8a839d91c1
2013-09-29 01:31:56 -03:00
Brian Wolff
37e32abb0e Add way of including all stderr output when executing command
This adds an option to wfShellExec (and convenience function
wfShellExecWithStderr), to make sure all stderr is duplicated
to stdout. The previous method of doing this was to include
2>&1 on the command line. However this did not redirect errors
from limit.sh (For example cgroups not set up, or if a command
reached the file size limit set by ulimit).

Not sure if this is the best approach, but it seems to work well,
and compared to most other approaches I considered, actually gets
the ulimit errors redirected too.

Currently some files fail to render with no error whatsoever,
hopefully this patch will make what went wrong more obvious.

Also fix a comment in wfShellExec that was incorrect (trailing \n),
and make the initial value of the return value variable be 200, so
if there's ever a bug in php where its not being set properly, it
would be immediately obvious what is happening.

Bug: 53824
Change-Id: I833aeb3ab9da726ecb97331369ea187daad7e795
2013-09-28 17:48:37 -03:00
Siebrand Mazeland
59f6fd0199 Change EXIF to Exif
Per https://en.wikipedia.org/wiki/Exchangeable_image_file_format. Spotted
by Shirayuki and documented on
https://translatewiki.net/wiki/Thread:Support/About_MediaWiki:Sesp-property-exif-data/en

Change-Id: I92ba67ec60ccfe7a173d950593357b86792b8ed3
2013-05-10 13:51:06 +02:00
umherirrender
ee31d37821 Fixed spacing in context/installer/media/templates/upload folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I9761be9fa47adc3554852a97b19792b4648466ad
2013-04-21 06:22:06 +00:00
umherirrender
6c278b6d7e fix some spacing
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
  calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays

Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
2013-03-25 22:22:46 +00:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
Platonides
d1bc1b968b Fixes for e288e4036
Changed static calls to instance functions.

Make BitmapHandler::rotate() non-static.

We don't have a Bitmap class. It should have
been falling back to BitmapHandler class.
(JpegHandler ← ExifBitmapHandler ← BitmapHandler)

Change-Id: I17be410456b00cef2ded8d6e2282ae0de4785695
2013-03-08 21:57:23 +01:00
Jan Gerber
e288e4036c (bug 33186) image rotate api
add api action imagerotate to rotate images.
	rotations are stored as a new version of the image.

Change-Id: Id15a92d19cda8256917e7e1e5ee4241012214102
2013-03-07 21:38:10 +00:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00