当前位置:网站首页>JS image resolution compression
JS image resolution compression
2022-06-23 00:45:00 【Ziwei front end】
/**
* @desc SVG turn PNG
* @param {Object} obj
* @param {Number} obj.scale The zoom
* @param {Number} obj.length length
* @param {String} obj.src Picture path
* @param {Boolean} obj.base64 Output data type Yes No base64
* @param {Function} obj.success Successful callback
* @param {Function} obj.error Failed callback
*/
function dealImage(obj) {
var img = new Image();
img.src = obj.src;
img.onload = function () {
// Default scale compression
var w = this.width,
h = this.height,
scale = w / h;
if (obj.length) {
if (w > h) {
w = obj.length;
h = (w / scale);
} else {
h = obj.length;
w = (h * scale);
}
} else {
w = obj.width || w;
h = obj.height || (w / scale);
}
// Generate canvas
var canvas = document.createElement('c边栏推荐
- 3dMax建模笔记(一):介绍3dMax和创建第一个模型Hello world
- Swiftui swift tutorial 14 useful array operators
- 通过天天基金投资基金安全吗?我打算开户买基金
- 详解openGauss多线程架构启动过程
- 3DMAX modeling notes (I): introducing 3DMAX and creating the first model Hello World
- Some thoughts about the technology of test / development programmers are very advanced, and they can't go on
- How to use enum data types
- 你踩过这些坑吗?谨慎在时间类型列上创建索引
- SAP mm transaction code vl04 create outbound delivery for sto
- 3 big questions! Redis cache exceptions and handling scheme summary
猜你喜欢

Mysql8.0 easily completes gtid master-slave replication

Cadence spb17.4 - Allegro - optimiser la spécification de l'angle de connexion de la polyligne pour une seule ligne électrique - polyligne à arc

What is the storage structure and mode of data in the database?

OSPF experiment in mGRE environment

數據庫中數據的儲存結構和方式是什麼?

Ros2 summer school 2022 transfer-

你踩过这些坑吗?谨慎在时间类型列上创建索引

SAP UI5 应用开发教程之一百零二 - SAP UI5 应用的打印(Print)功能实现详解试读版

Using geTx to build a more elegant structure of flutter pages

Kunlundb query optimization (III) sort push down
随机推荐
Explain the startup process of opengauss multithreading architecture in detail
如何入门机器学习?
TiDB VS MySQL
[initial launch] there are too many requests at once, and the database is in danger
Package management tools --npm, -cnpm, -yan, -cyarn
Introduction to the unique variable reading and writing function of Kunlun distributed database
Hierarchy selector
a++,++a,!,~
Tidb monitoring upgrade: a long way to solve panic
Have you stepped on these pits? Use caution when creating indexes on time type columns
Yyds dry goods counting tail recursion is better than recursion
Because I said: volatile is a lightweight synchronized, the interviewer asked me to go back and wait for the notice!
华为云如何实现实时音视频全球低时延网络架构【上】
Mysql8.0 easily completes gtid master-slave replication
層次選擇器
TIDB监控升级解决panic的漫漫探索之路
SwiftUI Swift 教程之 14 个有用的数组运算符
Shell view help
中国国际期货有限公司怎么样,是正规的期货公司吗?网上开户安全吗?
How to calculate the position of gold ETF