************************ // Image Processing Methods // ************************ // 
rotate image 90 degrees
@private
@return {?}
427361
function () {
                var _this = this;
                return new Promise(function (resolve, reject) {
                    _this.processing.emit(true);
                    setTimeout(function () {
                        /** @type {?} */
                        var dst = cv.imread(_this.editedImage);
                        // const dst = new cv.Mat();
                        cv.transpose(dst, dst);
                        cv.flip(dst, dst, 1);
                        cv.imshow(_this.editedImage, dst);
                        // src.delete();
                        dst.delete();
                        // save current preview dimensions and positions
                        /** @type {?} */
                        var initialPreviewDimensions = { width: 0, height: 0 };
                        Object.assign(initialPreviewDimensions, _this.previewDimensions);
                        /** @type {?} */
                        var initialPositions = Array.from(_this.points);
                        // get new dimensions
                        // set new preview pane dimensions
                        _this.setPreviewPaneDimensions(_this.editedImage);
                        // get preview pane resize ratio
                        /** @type {?} */
                        var previewResizeRatios = {
                            width: _this.previewDimensions.width / initialPreviewDimensions.width,
                            height: _this.previewDimensions.height / initialPreviewDimensions.height
                        };
                        // set new preview pane dimensions
                        _this.limitsService.rotateClockwise(previewResizeRatios, initialPreviewDimensions, initialPositions);
                        _this.showPreview().then(function () {
                            _this.processing.emit(false);
                            resolve();
                        });
                    }, 30);
                });
            }
818427
function(image) {
        var maskWidth = this._getMaskX(image.width);
        var maskHeight = this._getMaskY(image.height);
        var buf = this._getResizedImageBuffer(image, maskWidth, maskHeight);
        var mask = new Array(maskWidth * maskHeight);
        for (var y = 0; y < maskHeight; y++) {
            for (var x = 0; x < maskWidth; x++) {
                var idx = (y * maskWidth + x);
                var filled = this._checkFilledPixel(buf, idx);
                mask[idx] = filled ? 1 : 0;
            }
        }
        return mask;
    }
498554
public function rotateExif()
    {
        if (!in_array($this->fileType, array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM))) {
            $this->log("Autorotate ignored, EXIF not supported by this filetype.");
            return $this;
        }

        $exif = exif_read_data($this->pathToImage);

        if (!empty($exif['Orientation'])) {
            switch ($exif['Orientation']) {
                case 3:
                    $this->log("Autorotate 180.");
                    $this->rotate(180, $this->bgColor);
                    break;

                case 6:
                    $this->log("Autorotate -90.");
                    $this->rotate(-90, $this->bgColor);
                    break;

                case 8:
                    $this->log("Autorotate 90.");
                    $this->rotate(90, $this->bgColor);
                    break;

                default:
                    $this->log("Autorotate ignored, unknown value as orientation.");
            }
        } else {
            $this->log("Autorotate ignored, no orientation in EXIF.");
        }

        return $this;
    }
1083816
function(v) {
				var pt = this._firstPT, val;

				while (pt) {
					val = pt.c * v + pt.s;
					if (pt.r) {
						val = Math.round(val);
					}
					if (!pt.type) {
						pt.t[pt.p] = val;
					} else if (pt.type === 1) { //rgb()
						pt.t[pt.p] = "rgb(" + (val >> 0) + ", " + ((pt.gs + (v * pt.gc)) >> 0) + ", " + ((pt.bs + (v * pt.bc)) >> 0) + ")";
					} else if (pt.type === 2) { //rgba()
						pt.t[pt.p] = "rgba(" + (val >> 0) + ", " + ((pt.gs + (v * pt.gc)) >> 0) + ", " + ((pt.bs + (v * pt.bc)) >> 0) + ", " + (pt.as + (v * pt.ac)) + ")";
					} else if (pt.type === -1) { //non-tweening
						pt.t[pt.p] = pt.i;
					}
					pt = pt._next;
				}

				this._target.attr(this._props);

				//apply transform values like x, y, scaleX, scaleY, rotation, skewX, or skewY. We do these after looping through all the PropTweens because those are where the changes are made to scaleX/scaleY/rotation/skewX/skewY/x/y.
				if (this._transform) {
					pt = this._transform; //to improve speed and reduce size, reuse the pt variable as an alias to the _transform property
					var ang = pt.rotation,
						skew = ang - pt.skewX,
						a = Math.cos(ang) * pt.scaleX,
						b = Math.sin(ang) * pt.scaleX,
						c = Math.sin(skew) * -pt.scaleY,
						d = Math.cos(skew) * pt.scaleY,
						min = 0.000001,
						pxl = this._pxl,
						pyl = this._pyl;

					//some browsers have a hard time with very small values like 2.4492935982947064e-16 (notice the "e-" towards the end) and would render the object slightly off. So we round to 0 in these cases for both b and c. The conditional logic here is faster than calling Math.abs().
					if (b < min) if (b > -min) {
						b = 0;
					}
					if (c < min) if (c > -min) {
						c = 0;
					}
					pt.ox = this._pxg - (pxl * a + pyl * c); //we must record the offset x/y that we're making from the regular tx/ty (matrix.e and f) so that we can correctly interpret positional data in _getTransform(). See note there on tx and ox.
					pt.oy = this._pyg - (pxl * b + pyl * d);
					this._target.transform("m" + a + "," + b + "," + c + "," + d + "," + (pt.tx + pt.ox) + "," + (pt.ty + pt.oy));
				}

			}
487344
function(theta, delta) {
		var angle = mathUtils.degrees(theta);
		this.rotateRYB(angle * mathUtils.normalizedRandom());
		this.hsv[1] += delta * mathUtils.normalizedRandom();
		this.hsv[2] += delta * mathUtils.normalizedRandom();
		return this.setHSV(this.hsv);
	}
46292
function() {
                var _2x2x = this;

                var guard_file = 0;
                var guard_2x = 0;
                grunt.file.recurse(this.imgsrcdir, function(file) {
                    guard_file += 1;

                   

                    var srcextname = path.extname(file), 
                        srcdirname = path.dirname(file);
                    if (!grunt.file.isDir(_2x2x.imgdesdir)) {
                        grunt.file.mkdir(_2x2x.imgdesdir);
                    }
                    var has2x = (function() {
                        return file.indexOf('@2x') > -1;
                    })();

                    if(!has2x) {

                      return false;  
                    } 
                    guard_2x += 1;
                    _2x2x.series.push(function(callback) {
                        gm(file).size(function(err, features) {
                          
                            // find the @2x image and get it's normal name
                            var outfile = replace2x(file);
                            
                            var dstPath = _2x2x.imgdesdir + "/" +  outfile;
                            var final_width = features.width;
                            var final_height = features.height;
                            // fix the decimals width & height
                            if((features.height % 2)) {
                                final_height += 1;
                            }
                            if((features.width % 2)) {
                                final_width += 1;
                            }
                            if(!_2x2x.overwrite) {
                                // not overwrite
                                if(grunt.file.exists(dstPath)) {
                                    grunt.log.error((dstPath + "is existed already!"));
                                    return false;    

                                }
                                
                            }
                             gm(file).autoOrient().
                                resize(final_width / 2, final_height / 2, "!").
                                write(dstPath, function(err) {
                                  grunt.log.writelns((dstPath + " has been created !").green);
                                });
                            // gm(file).thumb(final_width / 2, final_height / 2, dstPath, _2x2x.quality, function() {
                            //    grunt.log.writelns((dstPath + " has been created !").green);
                            // });
                        });
                    }(file));    
                });
                if((guard_file != 0) && (guard_2x == 0)) {
                    grunt.log.error('no @2x image in the srcdir! ').red;
                }
                if(guard_file == 0) {
                    grunt.log.error('no image in the srcdir! ');
                }

                async.series(_2x2x.series, that.async());          
            }
1197645
function(size, callback) {
      var ratio = size.width / size.height;
      var cropPosition = {};
      var resizeWidth = width || Math.round(height * ratio);
      var resizeHeight = height || Math.round(width / ratio);

      if (crop && width && height) {
        if (ratio < width / height) {
          resizeHeight = Math.round(width / ratio);
          cropPosition = {x: 0, y: Math.round((resizeHeight - height) / 2)};
          crop = resizeHeight > height;
        } else {
          resizeWidth = Math.round(height * ratio);
          cropPosition = {x: Math.round((resizeWidth - width) / 2), y: 0};
          crop = resizeWidth > width;
        }
      }

      image
        .noProfile()
        .quality(quality)
        .resizeExact(resizeWidth, resizeHeight);

      if (crop)
        image.crop(width, height, cropPosition.x, cropPosition.y);

      image.write(thumbnailPath, callback);
    }
501507
function(current) {
        var bounds = this.getBoundsNoRotate(current);
        if (this._clip) {
            var worldWidth = current ?
                this._worldWidthCurrent : this._worldWidthTarget;
            var ratio = worldWidth / this.source.dimensions.x;
            var clip = this._clip.times(ratio);
            bounds = new $.Rect(
                bounds.x + clip.x,
                bounds.y + clip.y,
                clip.width,
                clip.height);
        }
        return bounds.rotate(this.getRotation(current), this._getRotationPoint(current));
    }
629429
function () {
            var /** @type {?} */ tickSize = this._tickIntervalPercent * 100;
            var /** @type {?} */ backgroundSize = this.vertical ? "2px " + tickSize + "%" : tickSize + "% 2px";
            var /** @type {?} */ axis = this.vertical ? 'Y' : 'X';
            // Depending on the direction we pushed the ticks container, push the ticks the opposite
            // direction to re-center them but clip off the end edge. In RTL languages we need to flip the
            // ticks 180 degrees so we're really cutting off the end edge abd not the start.
            var /** @type {?} */ sign = !this.vertical && this._direction == 'rtl' ? '-' : '';
            var /** @type {?} */ rotate = !this.vertical && this._direction == 'rtl' ? ' rotate(180deg)' : '';
            var /** @type {?} */ styles = {
                'backgroundSize': backgroundSize,
                // Without translateZ ticks sometimes jitter as the slider moves on Chrome & Firefox.
                'transform': "translateZ(0) translate" + axis + "(" + sign + tickSize / 2 + "%)" + rotate
            };
            if (this._isMinValue && this._thumbGap) {
                var /** @type {?} */ side = this.vertical ?
                    (this._invertAxis ? 'Bottom' : 'Top') :
                    (this._invertAxis ? 'Right' : 'Left');
                styles["padding" + side] = this._thumbGap + "px";
            }
            return styles;
        }
448237
function getImagePixels() {
    var w = width;
    var h = height;
    pixels = [];
    var data = image;
    var count = 0;

    for (var i = 0; i < h; i++) {

      for (var j = 0; j < w; j++) {

        var b = (i * w * 4) + j * 4;
        pixels[count++] = data[b];
        pixels[count++] = data[b + 1];
        pixels[count++] = data[b + 2];

      }

    }
  }
751427
function(d, cx, cy) {
    return this.transform({ rotation: d, cx: cx, cy: cy })
  }
996553
function() {
            this.x = this.body.p.x;
            this.y = this.body.p.y;
            this.rotation = this.body.a * RAD2DEG;
        }
408330
function photos_transform_rotate($photo_id, $degrees)
    {
        /** http://www.flickr.com/services/api/flickr.photos.transform.rotate.html */
        $this->request("flickr.photos.transform.rotate", array("photo_id" => $photo_id, "degrees" => $degrees), TRUE);
        return $this->parsed_response ? true : false;
    }
823862
public function correctOrientation()
    {
        try {
            $exif = exif_read_data($this->file);
        } catch (\Exception $e) {
            return $this;
        }
        if (!empty($exif['Orientation'])) {
            switch ($exif['Orientation']) {
                case 8:
                    $this->image = imagerotate($this->image, 90, 0);
                    break;
                case 3:
                    $this->image = imagerotate($this->image, 180, 0);
                    break;
                case 6:
                    $this->image = imagerotate($this->image, -90, 0);
                    break;
            }
        }
        return $this;
    }
665202
function(options) {
        if (!options || isNaN(options.angle)) {
            throw new Error('angle needs to be specified');
        }

        var bg = (options.bg || '000000').replace(/^#/, '');
        return this.append('rotate:angle=' + options.angle + ',bg=' + bg);
    }
627315
function (rotation) {
		var ret, 
			angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360;

		if (angle > 15 && angle < 165) {
			ret = 'right';
		} else if (angle > 195 && angle < 345) {
			ret = 'left';
		} else {
			ret = 'center';
		}
		return ret;
	}
39
function() {
        return {
            theta: Math.atan2(this.z, this.x),
            phi: Math.asin(this.y / this.length())
        };
    }