@@ -9,8 +9,13 @@ import * as fs from "node:fs";
99async function ffmpegDecodeToPng ( data , extname ) {
1010 return new Promise ( ( resolve , reject ) => {
1111 var fn = sharedLib . random . randomUUID ( ) ;
12+ < << << << HEAD
1213 fs . writeFileSync ( `/ydpsys/tmp/${ fn } .${ extname } ` , data ) ;
1314 var ffmpeg = childProcess . spawn ( 'chroot' , [ '.' , 'ffmpeg' , '-i' , `/tmp/${ fn } .${ extname } ` , `/tmp/${ fn } .png` ] , { cwd :'/ydpsys' } ) ;
15+ = === ===
16+ fs . writeFileSync ( `${ process . env [ 'ydpSysRootPath' ] } /tmp/${ fn } .${ extname } ` , data ) ;
17+ var ffmpeg = childProcess . spawn ( 'chroot' , [ '.' , 'ffmpeg' , '-i' , `/tmp/${ fn } .${ extname } ` , `/tmp/${ fn } .png` ] , { cwd :`${ process . env [ 'ydpSysRootPath' ] } ` } ) ;
18+ > >>> >>> 5220509 ( init . )
1419 var outTxt = '' ;
1520 ffmpeg . stdout . on ( 'data' , ( d ) => {
1621 outTxt += String ( d ) ;
@@ -24,13 +29,23 @@ async function ffmpegDecodeToPng(data,extname){
2429 } else {
2530 console . log ( '[libPic] ffmpeg exit with code' , code , '. ' ) ;
2631 }
32+ < << << << HEAD
2733 if ( ! fs . existsSync ( `/ydpsys/tmp/${ fn } .png` ) ) {
2834 reject ( outTxt ) ;
2935 return ;
3036 }
3137 var res = fs . readFileSync ( `/ydpsys/tmp/${ fn } .png` ) ;
3238 fs . unlinkSync ( `/ydpsys/tmp/${ fn } .png` ) ;
3339 fs . unlinkSync ( `/ydpsys/tmp/${ fn } .${ extname } ` ) ;
40+ = === ===
41+ if ( ! fs . existsSync ( `${ process . env [ 'ydpSysRootPath' ] } /tmp/${ fn } .png` ) ) {
42+ reject ( outTxt ) ;
43+ return ;
44+ }
45+ var res = fs . readFileSync ( `${ process . env [ 'ydpSysRootPath' ] } /tmp/${ fn } .png` ) ;
46+ fs . unlinkSync ( `${ process . env [ 'ydpSysRootPath' ] } /tmp/${ fn } .png` ) ;
47+ fs . unlinkSync ( `${ process . env [ 'ydpSysRootPath' ] } /tmp/${ fn } .${ extname } ` ) ;
48+ > >>> >>> 5220509 ( init . )
3449 resolve ( res ) ;
3550 } ) ;
3651 } ) ;
@@ -139,6 +154,10 @@ export async function processPic(path) {
139154 data = await ffmpegDecodeToPng ( data , 'pic' ) ;
140155 img = await imageJs . Image . load ( data ) ;
141156 } catch ( ee ) {
157+ < << << << HEAD
158+ = === ===
159+ console . log ( '[libPic] try ffmpeg failed. \n' , ee ) ;
160+ > >>> >>> 5220509 ( init . )
142161 return {
143162 type : 'text/plain' ,
144163 buff :Buffer . from ( `${ url } \n${ JSON . stringify ( opt ) } \n${ ee } ` )
@@ -172,7 +191,11 @@ export async function processPic(path) {
172191 type : 'image/png'
173192 } ;
174193}
194+ < << << << HEAD
175195export async function process ( Url , nowUrl , processServerHost , opt , svgOpt ) {
196+ === = ===
197+ export async function processLagacy ( Url , nowUrl , processServerHost , opt , svgOpt ) {
198+ > >>> >>> 5220509 ( init . )
176199 return new Promise ( ( resolve , reject ) => {
177200 try {
178201 /*
0 commit comments