Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
1d4e37c4
Commit
1d4e37c4
authored
11 years ago
by
Martin Nilsson
Browse files
Options
Downloads
Patches
Plain Diff
Moved the EXIF parsing version of JPEG decoder to exif_decode and keep decode/_decode as before.
parent
9b0de96d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/_Image_JPEG/module.pmod.in
+30
-43
30 additions, 43 deletions
src/modules/_Image_JPEG/module.pmod.in
with
30 additions
and
43 deletions
src/modules/_Image_JPEG/module.pmod.in
+
30
−
43
View file @
1d4e37c4
...
...
@@ -5,12 +5,9 @@
inherit @module@;
static object
exif_flip_jpeg(
object
img, mapping exif)
protected Image.Image
exif_flip_jpeg(
Image.Image
img, mapping exif)
{
if (!exif)
return img;
//Stdio.stderr->write("JPEG/EXIF: Orientation %O\n", exif->Orientation);
// FIXME: Can we use jpegtransform for any of this?
switch (exif->Orientation)
{
case "1": /* default orientation */
...
...
@@ -51,54 +48,44 @@ static object exif_flip_jpeg(object img, mapping exif)
return img;
}
object decode(string data, mapping|void options)
{
//Stdio.stderr->write("Image.JPEG overloaded decode.\r\n\n");
object img = ::decode(data, options || ([ ]) );
if (!img) // early exit if error
return img;
mapping exif = Standards.EXIF.get_properties(Stdio.FakeFile(data));
return exif_flip_jpeg(img, exif);
}
mapping _decode(string data, mapping|void options)
//! Decodes the image as @[_decode] would and then proceeds to decode
//! any EXIF information in the image. If it contain any Orientation
//! information the image will be flipped/rotated according to it. The
//! EXIF data will be returned as a mapping under the key
//! @expr{"exif"@}. If an error is encountered during the processing
//! of EXIF information, the backtrace will be returned under the key
//! @expr{"error"@}.
mapping exif_decode(string data, mapping|void options)
{
//Stdio.stderr->write("Image.JPEG overloaded _decode.\r\n\n");
mapping m = ::_decode(data, options || ([ ]) );
if (!m) // early exit if error
return m;
mapping exif = Standards.EXIF.get_properties(Stdio.FakeFile(data));
m->image = exif_flip_jpeg(m->image, exif);
if ((< "5", "6", "7", "8" >)[exif->Orientation])
{
/* If the image was flipped 90 or 270 degrees, we need to
* exchange the x/y metadata information.
*/
m->xsize = m->image->xsize;
m->ysize = m->image->ysize;
int tmp = m->x_density;
m->x_density = m->y_density;
m->y_density = tmp;
}
mapping exif = ([]);
mixed err = catch {
exif = Standards.EXIF.get_properties(Stdio.FakeFile(data)) || ([]);
m->image = exif_flip_jpeg(m->image, exif);
if ((< "5", "6", "7", "8" >)[exif->Orientation])
{
/* If the image was flipped 90 or 270 degrees, we need to
* exchange the x/y metadata information.
*/
m->xsize = m->image->xsize;
m->ysize = m->image->ysize;
int tmp = m->x_density;
m->x_density = m->y_density;
m->y_density = tmp;
}
};
if(err)
exif->error = err;
m->exif = exif;
return m;
}
mapping raw_decode(string data, mapping|void options)
{
// Compatibility function to bypass the overloading of _decode.
//Stdio.stderr->write("Image.JPEG overloaded _decode.\r\n\n");
return ::_decode(data, options || ([ ]) );
}
#else
constant this_program_does_not_exist = 1;
#endif // constant(@module@)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment