Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Allow an alternate library to be used to generate resized images #1576

Merged
merged 28 commits into from
Jun 15, 2016

Conversation

rnicholus
Copy link
Member

@rnicholus rnicholus commented May 25, 2016

  • Create event docs & stub for new callback/event.
  • Refactor scaling & thumbnail code to delegate to customResizer function (if provided). Support API methods too.
  • Determine or if it is possible/reasonable to orient images that are resized using external code.
  • Unit tests w/ at least one third-party scaling tool.
  • Update scaling & thumbnail feature doc pages.
  • Determine the consequences of using 3rd-party scaling code in iOS. If there is an issue here, include docs and/or code to make it easy to bypass third-party scaling code in iOS (or anytime).

closes #1525

@rnicholus
Copy link
Member Author

I have this mostly working at this point. Even though I have some more tasks to complete before calling this "done", it's certainly ready for someone to attempt to test out their favorite resize library alongside Fine Uploader. If anyone is interested in being a tester for this feature, please let me know. Of course, you will also be able to influence the feature before it is completed.

@rnicholus
Copy link
Member Author

rnicholus commented Jun 3, 2016

Core code on this feature is now complete. However, I'm unable to come up with a way to fix large image subsampling in iOS and still make use of one of the suggested third-party image resize libraries. I'm not sure this is even possible, or at least something that can be accomplished without integrating this complex logic into one of the third-party resize libraries. However, Fine Uploader will be able to properly orient all images before passing them off to a third-party resizer. On iOS, the internal resize/scaling code should be used instead of a third-party image resize plug-in. Documentation will include a way to easily implement this behavior.

@keyeh
Copy link

keyeh commented Jun 10, 2016

Great work. I'm ready to test if needed. I'm not targeting iOS, only desktop browsers though.

@rnicholus
Copy link
Member Author

Should be ready to test now. I've updated some docs, but not all (see the checkboxes in the pull request description for more details). Assuming you are using pica (and not supporting iOS), want to use pica both for resizing displayed thumbnails and for resizing images to be uploaded, your Fine Uploader initialization code will look like this:

var uploader = new qq.FineUploader({
    element: document.getElementById("uploader"),
    request: {
        endpoint: "/upload/endpoint"
    },
    thumbnails: {
        customResizer: function(resizeInfo) {
           return new Promise(function(resolve, reject) {
                pica.resizeCanvas(resizeInfo.sourceCanvas, resizeInfo.targetCanvas, {}, resolve)
           })
        },
        placeholders: {
            waitingPath: "/client/placeholders/waiting-generic.png",
            notAvailablePath: "/client/placeholders/not_available-generic.png"
        }
    },
    scaling: {
        customResizer: function(resizeInfo) {
           return new Promise(function(resolve, reject) {
                pica.resizeCanvas(resizeInfo.sourceCanvas, resizeInfo.targetCanvas, {}, resolve)
           })
        },
        sizes: [...]
    }
})

The scaling and thumbnails option documentation have been updated at http://docs.fineuploader.com/branch/feature_1525-better-scaling/.

@rnicholus
Copy link
Member Author

@keyeh Have you had a chance to verify on your end? I'm hoping to finish updating the docs and get this out the door within a week.

@rnicholus
Copy link
Member Author

This is ready to be released, and I plan on pushing out Fine Uploader 5.10.0 tomorrow unless I hear back from anyone regarding issue or requested changes.

@rnicholus rnicholus merged commit 07873ef into develop Jun 15, 2016
@rnicholus rnicholus deleted the feature/1525-better-scaling branch June 15, 2016 21:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants