|
| 1 | +package com.qiniu.qbox.fileop; |
| 2 | + |
| 3 | +import com.qiniu.qbox.auth.CallRet; |
| 4 | +import com.qiniu.qbox.auth.Client; |
| 5 | + |
| 6 | + |
| 7 | +public class ImageMogrify { |
| 8 | + public String thumbnail ; |
| 9 | + public String gravity ; |
| 10 | + public String crop ; |
| 11 | + public int quality ; |
| 12 | + public int rotate ; |
| 13 | + public String format ; |
| 14 | + public boolean autoOrient ; |
| 15 | + |
| 16 | + public String makeParams() { |
| 17 | + StringBuilder params = new StringBuilder() ; |
| 18 | + if (this.thumbnail != null && this.thumbnail != "") { |
| 19 | + params.append("/thumbnail/" + this.thumbnail) ; |
| 20 | + } |
| 21 | + if (this.gravity != null && this.gravity != "") { |
| 22 | + params.append("/gravity/" + this.gravity) ; |
| 23 | + } |
| 24 | + if (this.crop != null && this.crop != "") { |
| 25 | + params.append("/crop/" + this.crop) ; |
| 26 | + } |
| 27 | + if (this.quality > 0) { |
| 28 | + params.append("/quality/" + this.quality) ; |
| 29 | + } |
| 30 | + if (this.rotate > 0) { |
| 31 | + params.append("/rotate/" + this.rotate) ; |
| 32 | + } |
| 33 | + if (this.format != null && this.format != "") { |
| 34 | + params.append("/format/" + this.format) ; |
| 35 | + } |
| 36 | + if (this.autoOrient) { |
| 37 | + params.append("/auto-orient") ; |
| 38 | + } |
| 39 | + return params.toString() ; |
| 40 | + } |
| 41 | + |
| 42 | + public String makeRequest(String url) { |
| 43 | + return url + "?imageMogr" + this.makeParams() ; |
| 44 | + } |
| 45 | + |
| 46 | + public CallRet call(String url) { |
| 47 | + CallRet ret = new Client().call(url) ; |
| 48 | + return ret; |
| 49 | + } |
| 50 | +} |
0 commit comments