code: fix psd reading fail image

This commit is contained in:
ShawnPhang 2024-08-18 21:09:08 +08:00
parent 2878064b76
commit cba825cdbf
2 changed files with 18 additions and 14 deletions

View File

@ -3,9 +3,11 @@
* @Date: 2024-08-17 18:45:24 * @Date: 2024-08-17 18:45:24
* @Description: * @Description:
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2024-08-17 18:46:58 * @LastEditTime: 2024-08-18 20:49:49
*/ */
export function createBase64(src: any, { width, height }: any) { export function createBase64(src: any, { width, height }: any) {
let result = ''
if (src && width) {
const canvas = document.createElement('canvas') const canvas = document.createElement('canvas')
canvas.width = width canvas.width = width
canvas.height = height canvas.height = height
@ -17,5 +19,7 @@ export function createBase64(src: any, { width, height }: any) {
pixelData[i] = src[i] pixelData[i] = src[i]
} }
context.putImageData(imageData, 0, 0) context.putImageData(imageData, 0, 0)
return canvas.toDataURL('image/png') result = canvas.toDataURL('image/png')
}
return result
} }

View File

@ -3,7 +3,7 @@
* @Date: 2022-01-10 14:57:53 * @Date: 2022-01-10 14:57:53
* @Description: Psd文件解析 * @Description: Psd文件解析
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2024-08-17 18:53:35 * @LastEditTime: 2024-08-18 21:06:05
--> -->
<template> <template>
<div id="page-design-index" ref="pageDesignIndex"> <div id="page-design-index" ref="pageDesignIndex">