aliyun-oss-react-native

ImageProcessManager.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import React, { Component } from 'react';
  2. import {
  3. Platform,
  4. StyleSheet,
  5. Text,
  6. View,
  7. Alert,
  8. Button,
  9. ScrollView,
  10. Image
  11. } from 'react-native';
  12. //导入样式
  13. import { styles } from '../CSS/global.js'
  14. export class ImageProcessManager extends Component {
  15. render() {
  16. return (
  17. <View style={styles.item}>
  18. <Text style={styles.description}>图片处理</Text>
  19. <View style={styles.detailitem}>
  20. <View style={styles.button}>
  21. <Button style={styles.button}
  22. onPress={this.handClick.bind(this,"GeShi")}
  23. title="格式转换"
  24. color="#841584"
  25. />
  26. </View>
  27. <View style={styles.button}>
  28. <Button style={styles.button}
  29. onPress={this.handClick.bind(this,"Scale")}
  30. title="缩放比例"
  31. color="#841584"
  32. />
  33. </View>
  34. <View style={styles.button}>
  35. <Button style={styles.button}
  36. onPress={this.handClick.bind(this,"Cut")}
  37. title="裁剪比例"
  38. color="#841584"
  39. />
  40. </View>
  41. <View style={styles.button}>
  42. <Button style={styles.button}
  43. onPress={this.handClick.bind(this,"Rotate")}
  44. title="旋转操作"
  45. color="#841584"
  46. />
  47. </View>
  48. <View style={styles.button}>
  49. <Button style={styles.button}
  50. onPress={this.handClick.bind(this,"Effect")}
  51. title="图片效果"
  52. color="#841584"
  53. />
  54. </View>
  55. <View style={styles.button}>
  56. <Button style={styles.button}
  57. onPress={this.handClick.bind(this,"ShuiYin")}
  58. title="水印操作"
  59. color="#841584"
  60. />
  61. </View>
  62. </View>
  63. </View>
  64. )
  65. }
  66. handClick (e) {
  67. switch (e) {
  68. case "GeShi" : {
  69. //备注第三个参数必须穿入字符串
  70. AliyunOSS.asyncDownload('luozhang002','yanxing',"",{"x-oss-process":'image/format,jpg'}).then((e)=>{
  71. Alert.alert(e)
  72. console.log(e)
  73. }).catch((e)=>{
  74. console.log(e)
  75. })
  76. } break;
  77. case 'Scale': {
  78. AliyunOSS.asyncDownload('luozhang002','yanxing',"",{"x-oss-process":'image/resize,h_100'}).then((e)=>{
  79. Alert.alert(e)
  80. console.log(e)
  81. }).catch((e) => {
  82. console.log(e)
  83. })
  84. } break;
  85. case 'cut' : {
  86. AliyunOSS.asyncDownload('luozhang002','yanxing',"",{"x-oss-process":'image/circle,r_100'}).then((e)=>{
  87. Alert.alert(e)
  88. console.log(e)
  89. }).catch((e)=>{
  90. console.log(e)
  91. })
  92. } break;
  93. case 'Rotate': {
  94. AliyunOSS.asyncDownload('luozhang002','yanxing',"",{"x-oss-process":'image/resize,w_100/auto-orient,1'}).then((e)=>{
  95. Alert.alert(e)
  96. console.log(e)
  97. }).catch((e)=>{
  98. console.log(e)
  99. })
  100. } break;
  101. case "Effect": {
  102. // image/bright,50
  103. AliyunOSS.asyncDownload('luozhang002','yanxing',"",{"x-oss-process":'image/bright,50'}).then((e)=>{
  104. Alert.alert(e)
  105. console.log(e)
  106. }).catch((e)=>{
  107. console.log(e)
  108. })
  109. } break;
  110. case "ShuiYin" : {
  111. let xOss = "image/resize,w_400/watermark,image_cGFuZGEucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2UvcmVzaXplLFBfMzA,t_90,g_se,x_10,y_10"
  112. AliyunOSS.asyncDownload('luozhang002','zhongji',"",{"x-oss-process":xOss}).then((e)=>{
  113. Alert.alert(e)
  114. console.log(e)
  115. }).catch((e)=>{
  116. console.log(e)
  117. })
  118. } break;
  119. default : break;
  120. } //end switch
  121. }
  122. }