Viewing File: /usr/local/cpanel/base/cjt/image_resizer-min.js
(function(window){"use strict";var CPANEL=window.CPANEL,document=window.document;var _canvas,_context,_img;function _init(){if(!_context){_canvas=document.createElement("canvas");_context=_canvas.getContext("2d")}}function verify_client_capability(){try{_init();return true}catch(e){return false}}function get_resized_image_as_data_url(opts){_init();var box_width=opts.width;var box_height=opts.height;var img_width=opts.image.width;var img_height=opts.image.height;var scale=Math.min(box_height/img_height,box_width/img_width);var target_width=img_width*scale;var target_height=img_height*scale;var x_offset=Math.round((box_width-target_width)/2);var y_offset=Math.round((box_height-target_height)/2);_canvas.width=box_width;_canvas.height=box_height;_context.drawImage(opts.image,x_offset,y_offset,target_width,target_height);return _canvas.toDataURL(opts.type,opts.quality)}function resize_data_url_image(opts){var myopts=Object.create(opts);if(!_img){_img=document.createElement("img")}var callback=opts.callback;if(typeof callback==="function"){callback={success:callback}}_img.onload=function(e){myopts.image=_img;callback.success(get_resized_image_as_data_url(myopts))};_img.onerror=callback.failure||Object;_img.src=opts.image}CPANEL.image_resizer={verify_client_capability:verify_client_capability,get_resized_image_as_data_url:get_resized_image_as_data_url,resize_data_url_image:resize_data_url_image}})(window);
Back to Directory
File Manager