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

ps做的图片能做直接做网站吗怎么优化推广自己的网站

ps做的图片能做直接做网站吗,怎么优化推广自己的网站,哈尔滨网站建设一薇ls15227,可以用自己的电脑做网站主机因为我的一个项目是使用GitHub action来实现编译和部署的,而且这个android项目的icon很有可能会发生变化,所以需要在脚本中实现自动化生成icon的功能,所以这里就写了一个js脚本来做这个事情 这个脚本可以输入一个图片地址,然后生…

因为我的一个项目是使用GitHub action来实现编译和部署的,而且这个android项目的icon很有可能会发生变化,所以需要在脚本中实现自动化生成icon的功能,所以这里就写了一个js脚本来做这个事情

这个脚本可以输入一个图片地址,然后生成android项目的icon图标。

脚本文件内容:

const sharp = require('sharp')
const fs = require('fs-extra')
const path = require('path')
const { program } = require('commander')const DENSITIES = {mdpi: 48,hdpi: 72,xhdpi: 96,xxhdpi: 144,xxxhdpi: 192,
}program.requiredOption('-i, --input <file>', 'Path to source PNG').option('-o, --output <dir>', 'Output directory', 'res').option('--rounded', 'Apply circular mask to icons').option('--copy-to <androidResDir>', 'Copy icons to Android res directory')program.parse(process.argv)
const options = program.opts()async function generateAdaptiveIcons(input, outputDir) {for (const [dpi, size] of Object.entries(DENSITIES)) {const mipmapDir = path.join(outputDir, `mipmap-${dpi}`)await fs.ensureDir(mipmapDir)const foregroundPath = path.join(mipmapDir,'ic_launcher_foreground.png')const backgroundPath = path.join(mipmapDir,'ic_launcher_background.png')const legacyPath = path.join(mipmapDir, 'ic_launcher.png')const img = sharp(input).resize(size, size)const rounded = options.rounded? img.composite([{input: Buffer.from(`<svg><circle cx="${size / 2}" cy="${size / 2}" r="${size / 2}" fill="white"/></svg>`),blend: 'dest-in',},]): imgawait rounded.toFile(foregroundPath)await sharp({create: {width: size,height: size,channels: 4,background: '#FFFFFF',},}).png().toFile(backgroundPath)// legacy fallbackawait rounded.toFile(legacyPath)}// Generate XMLconst xmlPath = path.join(outputDir, 'mipmap-anydpi-v26')await fs.ensureDir(xmlPath)await fs.writeFile(path.join(xmlPath, 'ic_launcher.xml'),`
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"><background android:drawable="@mipmap/ic_launcher_background"/><foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>`.trim())await fs.writeFile(path.join(xmlPath, 'ic_launcher_round.xml'),`
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"><background android:drawable="@mipmap/ic_launcher_background"/><foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>`.trim())console.log('✅ Adaptive icons generated.')
};(async () => {const { input, output, copyTo } = optionsconst outPath = path.resolve(output)await generateAdaptiveIcons(input, outPath)if (copyTo) {const dest = path.resolve(copyTo)await fs.copy(outPath, dest, { overwrite: true })console.log(`📦 Icons copied to Android res dir: ${dest}`)}
})()

使用说明:

node ./generateIcons.cjs -i pakeplus.png --copy-to app/src/main/res

生成圆角图标:

node ./generateIcons.cjs -i pakeplus.png --rounded --copy-to app/src/main/res

最后生成的结果:

http://www.dtcms.com/wzjs/514089.html

相关文章:

  • 东莞公司建设网站制作广州网站定制多少钱
  • 余姚网站建设设计厦门关键词优化seo
  • 网站建设会计线上线下整合营销方案
  • 城阳网站开发公司电话百度平台推广
  • 网站开发运行详细步骤免费注册网页网址
  • 网站建设智能优化seo是什么意思中文
  • 活动营销推广方案廊坊seo关键词排名
  • 网站开发并发处理百度seo发帖推广
  • 天蓝色网站成都高端企业网站建设
  • 东营设计网站建设张家界网站seo
  • 移动网站建设的前景在线超级外链工具
  • 风险的网站怎么出现天天自学网网址
  • 网站建设400电话链接推广
  • 侯马市网站建设公司广州seo网站管理
  • 建设外贸网站费用指数基金定投技巧
  • 河池企业网站开发公司年轻人不要做网络销售
  • 怎么看网站是谁做的罗湖区seo排名
  • 企业做网站营销的四大途径大连网站建设费用
  • 扬州网站建设哪家公司好上海今日头条新闻
  • 个人网站做淘宝客商城免费网站怎么注册
  • app制作平台大全班级优化大师免费下载
  • 企业网站建设重要性产品市场调研怎么做
  • 沧州北京网站建设百度推广登录入口下载
  • 做淘宝客网站需要做后台吗百度手机助手下载正版
  • 怎样建设企业网站 用于宣传微信管理系统软件
  • 网站建设招聘百度一下百度主页官网
  • 做的最好的微电影网站有哪些百度搜索引擎广告投放
  • html5网站开发费用百度云搜索引擎
  • 做美食网站的图片大全seo搜索优化工程师招聘
  • 网站建设项目外包合同范本推广普通话的意义论文