Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Automatic EXIF metadata stripping from uploaded JPEGs?

I'm a total Vanilla n00b, just discovered that fine piece of forum software a little less than two weeks ago, and I'm sucking in all the info I can get in the shortest possible time. Got my first Vanilla forum up and running within a week :)

I'm not capable to write my own plugins yet, although I'm trying to get the hang of it.

There is one very interesting functionality I'm after right now: Automatic EXIF metadata stripping from uploaded JPEGs (using the FileUpload plugin) with imagemagick.

Took a look and found such a plugin for Wordpress (which I have attached here).

Can anybody with the knowledge please take a look and tell me, if/how it could be implemented?
Would it be a modification to FileUpload?
Or an own plugin?

Comments

  • I am surprised, nobody interested? After all picture handling is one major feature of a forum, and I think two functions in particular are very useful after image upload:

    1. Resize to configurable values (for example setting max 800x600) and if JPEG set quality to a configurable value (for example 85% seems to be appropriate) to keep loading times low (people tend to upload high megapixel photos directly from their cameras)
    2. Strip all metadata (especially to prevent localization through GPS metadata)

    The enclosed PHP from the Wordpress addon could be a starting point, but I am really not ready for coding my own plugin yet, although I guess it should not be hard to implement.

  • whu606whu606 I'm not a SuperHero; I just like wearing tights... MVP

    although I guess it should not be hard to implement.

    Seriously, that has to be the phrase most likely to get developers fighting mad.

    And when it is coupled with

    I am really not ready for coding my own plugin yet

    you can only be grateful that this is a virtual conversation!

    If you don't know how to do it, then you have no idea if it is easy or hard.

    If it's that easy, you can do it.

    If it's not, then don't assume that others will find it easy.

  • @whu606

    Sorry, no offense intended, must be a tender point.

    I assume it's not that hard because of the way other plugins extend the functionality of the core.

    I am very interested in that functionality and I am willing to put my time in learning how to do it, but some suggestions from people already knowing how to do such things would have been nice, especially some ideas on where to start.

    I'm gonna read up on plugin-development asap, I intend to join github, and I'll make the plugins I create available to the public for free.

  • peregrineperegrine MVP
    edited May 2013

    in addition to @whu606 insightful comments...

    @MasterOne
    I am surprised, nobody interested?

    since you want a plugin and not a few minutes of help with something you developed.

    you might consider publicly pledging a sum of $$ perhaps someone who will take up the cause and do it for you. just as the poll plugin (to be developed) and the badges plugin was developed.


    money sometimes is more motivating than "not hard to implement". Thanks is nice.


    And clicking on "insightful" (which some questioners can't seem to do for a good answer!)


    ... are nice but as one famous poster said "It don't put food on the table".

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine

    I understand, and I really wasn't aware that my comment was that offending. Sorry again, I want to participate, and I want to know how to do it, I'm still a total n00b on Vanilla, but I'm eager to learn. I would pledge if the community I take care of is willing to donate, as this is not something I can decide on my own.

  • hgtonighthgtonight ∞ · New Moderator
    edited May 2013

    @MasterOne said:
    I am very interested in that functionality and I am willing to put my time in learning how to do it, but some suggestions from people already knowing how to do such things would have been nice, especially some ideas on where to start.

    I'm gonna read up on plugin-development asap, I intend to join github, and I'll make the plugins I create available to the public for free.

    Welcome, Vanilla is a treat to work with!

    @peregrine said:
    since you want a plugin and not a few minutes of help with something you developed.

    Helping out with a specific issue is where this forum really excels in my opinion.

    EDIT - Cross-post

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @MasterOne said:
    I'm a total Vanilla n00b, just discovered that fine piece of forum software a little less than two weeks ago, and I'm sucking in all the info I can get in the shortest possible time. Got my first Vanilla forum up and running within a week :)

    I'm not capable to write my own plugins yet, although I'm trying to get the hang of it.

    There is one very interesting functionality I'm after right now: Automatic EXIF metadata stripping from uploaded JPEGs (using the FileUpload plugin) with imagemagick.

    Took a look and found such a plugin for Wordpress (which I have attached here).

    Can anybody with the knowledge please take a look and tell me, if/how it could be implemented?
    Would it be a modification to FileUpload?
    Or an own plugin?

  • Get the app: Photo Investigator.
    It will tell you where a photo was taken and show you the location on a map, and you can scroll through pictures in your album seeing each location, one after the other without having to exit the app and go back in with a different pic. great app and you can get ideas from the code

  • hgtonighthgtonight ∞ · New Moderator

    [Human] spam?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • MasterOneMasterOne ✭✭
    edited September 2013

    Scum? Or just OT?

    Anyway, that topic is still in my head. Other duties prevented me from following it any further, in fact I had no time to even keep up-to-date with Vanilla's progress or adding any more plugins. It's cumbersome, because right now I am resizing and stripping uploaded pics manually, but in the the end I'll never be a dev, just a user.

    Anyway the Vanilla software is just awesome, and I don't regret having installed 2.1b1 on a production site. Will upgrade to 2.1b2 as soon as I find the time.

  • ShadowdareShadowdare r_j MVP
    edited September 2013

    One way to strip EXIF metadata from a JPEG image in PHP is to recreate the image and save it instead of the original image.

    For example, you can use the GD image functions to recreate the image:

    <?php
    // This example procedure requires that you have PHP GD installed on your web server.
    // Define the paths to the images.
    $imagePath = 'exampleWithEXIF.jpg';
    $newImagePath = 'exampleWithoutEXIF.jpg';
    $newImageQuality = 100; // The compression quality of the new image to be created from 0 (worst) to 100 (best).
    
    // Load the original image into memory.
    $image = imagecreatefromjpeg($imagePath);
    
    // If the image was loaded successfully, then recreate the image.
    if($image) {
       // Recreate the image without the EXIF metadata.
       // Print an error if it failed to create the new image.
       if(imagejpeg($image, $newImagePath, $newImageQuality))
          echo "The new image was created successfully without the EXIF metadata.";
       else
          echo "The new image failed to be created. Make sure that the new folder path has write permissions set properly.";
       
       // Clear the original image from memory.
       imagedestroy($image);
    
       // You can also delete the original image from file storage if it wasn't stored in the /tmp folder earlier.
    } else {
       // If the image failed to be created, then print an error message.
       echo "Unable to open the original image. Make sure that it exists.";
    }
    ?>
    

    You would have to incorporate this into Vanilla by modifying or creating a new plugin to do what you want.

    Add Pages to Vanilla with the Basic Pages app

  • Thanks, @Shadowdare, that's over my head right now, but we'll see. For my purpose it would have to be an extension of the FileUpload plugin, so if the upload is an image, strip metadata, reduce compression quality to 85% and resize to 800x600 / 600x800. I have a feeling that it should not be difficult to achieve, but sadly I'm nowhere near to implement such a functionality.

  • R_JR_J Ex-Fanboy Munich Admin

    @MasterOne: you're right. What you're asking for shouldn't be too hard and it is also true what @hgtonight said (half a year ago): this forum is great when you're asking specific questions.

    I do not know the FileUpload plugin, but I assume that it shouldn't be too hard to find out the place to put in the file transformation code, even for someone who can not program at all. Reading code is a lot easier than writing code.

    The above code @Shadowdare has posted is nearly all you need. Even a non programmer could find the place to set compression ratio to 85% in there, because the code is well commented.
    You'll have to search for the resize part but you'll find it if you google for things like "php gd resize". But keep in mind that there could be images with other ratios than 4:3 and even pictures below 800x600. You didn't want to blow them up, do you?

    Even if you are no programmer at all, I think you could find out how to do what you achieve and if you bring the skeleton, here are enough helpful people that will help you work out the details.

  • ShadowdareShadowdare r_j MVP
    edited September 2013

    You're welcome, @MasterOne. I put in a lot of comments in the example to help you figure out what each line of the procedure is doing. A lot of people in this community would be glad to help you out with questions you may have about Vanilla and even PHP in general, so feel free to take your time.

    Have a look at the Gdn_UploadImage class in Vanilla located at /library/core/class.uploadimage.php for some methods that would be very handy to use in a plugin. The SaveImageAs() method in the class has a comment block above it with info on changing the image quality and the dimensions of an image.

    Also, check out @chuck911's ImageUpload plugin for an example on how to use some of the methods from the Gdn_UploadImage class.

    Add Pages to Vanilla with the Basic Pages app

  • @R_J, hopefully the forum users will not use any other format than 4:3 for picture, at least they did not so far, I guess there should be a check on ratio as well. Any yes, if less than 800x600 the picture should be blown up to 800x600, as I have seen pictures with 640x480 that just looked better when resized to 800x600 (I consider anything less than 800x600 just too small, 800x600 has proven to be the right size for forum pictures, which also lead to small file sizes when using 85% JPEG quality). I have made myself a note to follow up on that matter. ;)

  • @Shadowdare

    do you have php 5.4?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • In honestly you should blame phone for relying on thing like EXIF. I hardly see it as a requirement of servers to support this.

    If you want a facility to reorientate that the image, then develop it. After all you said it is not hard, so go ahead and do it.

    grep is your friend.

  • R_JR_J Ex-Fanboy Munich Admin

    My old father is an EXIF fan! He has a camera with GPS and he loves to show us on our computer where he has been.

    I've started to hate EXIF, though...

  • I have no problem with meta, but it should be processed if you wan to upload.

    grep is your friend.

Sign In or Register to comment.