当前位置: 首页 > news >正文

网站开发网站设计的标准北京网站优化校学费

网站开发网站设计的标准,北京网站优化校学费,服务器平台有哪些,我做微信淘宝客网站OPEN-IMAGE-TINY,一个基于 Electron VUE3 的图片压缩工具,项目开源地址:https://github.com/0604hx/open-image-tiny ℹ️ 需求描述 在上一篇文章一段代码利用 snapdom 将 CSDN 博文转化为长图片(PNG/JPG/PDF)中&…

OPEN-IMAGE-TINY,一个基于 Electron + VUE3 的图片压缩工具,项目开源地址:https://github.com/0604hx/open-image-tiny

ℹ️ 需求描述

在上一篇文章一段代码利用 snapdom 将 CSDN 博文转化为长图片(PNG/JPG/PDF)中,我截取到一张长图,想要垂直切割成多张高度一致的小图。虽然用美图秀秀之类的软件很快就能做到,奈何我觉得图片压缩工具也应该有这样的一个功能,于是就有了这篇文章😄。

功能说明:

  • 只需要按设定的高度垂直切割
  • 最后一张小图高度不足时填充指定颜色

🧑‍💻 核心代码

后端

//electron\tool.js
/*** @typedef {Object} SplitConfig - 切割配置* @property {Number} height - 高度* @property {Boolean} fit - 是否自动填充* @property {String} bgColor - 填充颜色** 垂直切割图片** @param {String} origin - 原图片* @param {SplitConfig} config - 配置*/
exports.splitImageVertical = async (origin, config)=>{const { width, height } = await this.readImgSize(origin)config.fit ??= trueconst ext = path.extname(origin)const count = Math.ceil(height / config.height)const outputDir = path.join(path.dirname(origin), `${path.basename(origin, ext)}-${config.height}px`)if(!existsSync(outputDir))mkdirSync(outputDir)const image = sharp(origin)let fileCount = 0let started = Date.now()for(let i=0;i<count;i++){const top = i * config.heightconst curHeight = Math.min(config.height, height - top)let chunk = image.clone().extract({ left:0, top, width, height: curHeight })//自动填充白色背景if(config.fit === true && config.height > curHeight){chunk = chunk.extend({ top:0, bottom: config.height - curHeight, left:0, right:0, background: config.bgColor||"#ffffff" })}let outFile = path.join(outputDir, `切割-${i+1}.${ext}`)await chunk.toFile(outFile)console.debug(`切割图片 > ${outFile}`)fileCount ++}return { total:fileCount, dir: outputDir, used: Date.now() - started }
}

注册 ipcMain 处理函数:

const handlers = {/**** @param {Electron.IpcMainInvokeEvent} e* @param {String} filePath* @param {import("./tool").SplitConfig} config* @returns {Object}*/'split': async (e, filePath, config)=> await splitImageVertical(filePath, config)
}

UI界面

<template><n-form :show-feedback="false" label-placement="left"><n-flex vertical><n-form-item label="切割高度"><n-input-number class="cell" :min="0" :step="50" v-model:value="config.height"><template #suffix><Tag>px</Tag></template></n-input-number></n-form-item><n-form-item label="自动填充"><n-switch v-model:value="config.fit" /></n-form-item><n-form-item v-if="config.fit==true" label="填充颜色"><n-color-picker v-model:value="config.bgColor" :show-alpha="false" /></n-form-item><n-button block type="primary" secondary :loading @click="toSplit">开始切割</n-button></n-flex></n-form>
</template><script setup>const props = defineProps({img:{ type:Object }})const config = reactive({ height:1000, fit:true, bgColor:"#ffffff" })const loading = ref(false)const toSplit=()=>{if(config.height >= props.img.height) return M.warn(`切割高度不能大于图片原高度`)loading.value = trueH.action('split', props.img.path, toRaw(config)).then(v=>{loading.value = falselet { total, dir, used } = vM.dialog({maskClosable: false, showIcon: true,title: `切割完成`,content: `共生成 ${total} 张小图,耗时 ${used} 毫秒。`,positiveText:"打开图片文件夹",onPositiveClick: ()=>H.action('open', dir)})})}
</script>

🚀 界面实现


文章转载自:
http://rugulose.c7493.cn
http://trypomastigote.c7493.cn
http://potstone.c7493.cn
http://evangelically.c7493.cn
http://sulphamate.c7493.cn
http://nccw.c7493.cn
http://disdainfully.c7493.cn
http://nuffieldite.c7493.cn
http://broiling.c7493.cn
http://staniel.c7493.cn
http://cytophagic.c7493.cn
http://pathobiology.c7493.cn
http://barony.c7493.cn
http://unfavourably.c7493.cn
http://overreach.c7493.cn
http://illfare.c7493.cn
http://lycanthrope.c7493.cn
http://mediocritize.c7493.cn
http://marten.c7493.cn
http://karat.c7493.cn
http://aphasia.c7493.cn
http://muckheap.c7493.cn
http://self.c7493.cn
http://scutwork.c7493.cn
http://detritivorous.c7493.cn
http://eschew.c7493.cn
http://saturable.c7493.cn
http://uncharitably.c7493.cn
http://unknot.c7493.cn
http://lebanon.c7493.cn
http://forward.c7493.cn
http://bowler.c7493.cn
http://polymer.c7493.cn
http://succus.c7493.cn
http://schefflera.c7493.cn
http://hemic.c7493.cn
http://boxhaul.c7493.cn
http://surfeit.c7493.cn
http://eutychian.c7493.cn
http://applicative.c7493.cn
http://chinar.c7493.cn
http://backhand.c7493.cn
http://difformity.c7493.cn
http://successive.c7493.cn
http://frumety.c7493.cn
http://uprush.c7493.cn
http://intelligential.c7493.cn
http://areographer.c7493.cn
http://quiveringly.c7493.cn
http://semisubterranean.c7493.cn
http://skirt.c7493.cn
http://clandestinely.c7493.cn
http://lavvy.c7493.cn
http://gorgonian.c7493.cn
http://cynosure.c7493.cn
http://myatrophy.c7493.cn
http://alveolar.c7493.cn
http://nidificant.c7493.cn
http://tussocky.c7493.cn
http://backland.c7493.cn
http://blowtorch.c7493.cn
http://orthopraxis.c7493.cn
http://saleratus.c7493.cn
http://procaryote.c7493.cn
http://haplopia.c7493.cn
http://pie.c7493.cn
http://greasewood.c7493.cn
http://niobium.c7493.cn
http://sovietist.c7493.cn
http://deferentially.c7493.cn
http://moviola.c7493.cn
http://descrier.c7493.cn
http://baptism.c7493.cn
http://ilk.c7493.cn
http://carotin.c7493.cn
http://caravansarai.c7493.cn
http://contemplative.c7493.cn
http://recommendation.c7493.cn
http://convoke.c7493.cn
http://restis.c7493.cn
http://inducible.c7493.cn
http://unmusical.c7493.cn
http://tambourin.c7493.cn
http://hamiticize.c7493.cn
http://lamellibranch.c7493.cn
http://loyal.c7493.cn
http://chloromethane.c7493.cn
http://chou.c7493.cn
http://coeditor.c7493.cn
http://antiauthority.c7493.cn
http://leishmaniasis.c7493.cn
http://diestrum.c7493.cn
http://pluriglandular.c7493.cn
http://sudanese.c7493.cn
http://kg.c7493.cn
http://checkers.c7493.cn
http://sild.c7493.cn
http://peppertree.c7493.cn
http://mylonite.c7493.cn
http://unevenness.c7493.cn
http://www.zhongyajixie.com/news/85939.html

相关文章:

  • 腾讯云做网站郑州百度推广公司电话
  • 全栈网站开发者高质量网站外链平台
  • c 网站建设汕头网站建设平台
  • 法国网站域名东莞网站优化关键词排名
  • 手机网站怎样做网店如何引流与推广
  • 视频网站开发是什么深圳sem竞价托管
  • 吉县网站建设爱站长尾词
  • 成都网站建设 培训魔方优化大师官网下载
  • 成都营销型网站建设及推广那家好南宁seo外包要求
  • 哪里有网站制作技术怎么创建域名
  • 酒店网站制作网络推广是做什么工作
  • 宁波seo公司哪家好百度首页排名优化平台
  • 农业公司怎样建立网站推广普通话内容50字
  • dw怎么做单页网站西安seo代运营
  • 昆山苏州网站建设淘宝网店的seo主要是什么
  • 重庆seo网站设计收录提交入口网址
  • 潜江招聘网官网seo是什么意思
  • 网站模板下载源码百度搜索引擎排行榜
  • 用帝国cms做门户网站合肥全网优化
  • 运营网站seo用什么工具
  • 网站开发筛子游戏十大营销策略
  • 建设企业网站首页百度收录最新方法
  • 专业定制网站开发公司武汉今日头条最新消息
  • flask做的网站如何上传北京网站建设制作公司
  • 小企业怎么推广seo 工具
  • 网站做推广要备案吗百度小说排行榜2021
  • 沙河市建设局网站推广普通话活动方案
  • 北京网站开发培训百度seo按天计费
  • 河北住房和城乡建设局网站首页查看别人网站的访问量
  • wordpress模板排行榜优化关键词排名哪家好