動画はimagemagickで変換できない
This commit is contained in:
		
							parent
							
								
									760b90a84b
								
							
						
					
					
						commit
						5172ef247b
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -54,8 +54,14 @@ interface ISend {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function thumbnail(data: stream.Readable, type: string, resize: number): ISend {
 | 
					function thumbnail(data: stream.Readable, type: string, resize: number): ISend {
 | 
				
			||||||
	const readable: stream.Readable = (() => {
 | 
						const readable: stream.Readable = (() => {
 | 
				
			||||||
		// 動画か画像であれば
 | 
							// 動画であれば
 | 
				
			||||||
		if (/^(?:video|image)\/.*$/.test(type) || type == 'application/xml') {
 | 
							if (/^video\/.*$/.test(type)) {
 | 
				
			||||||
 | 
								// 実装は先延ばし
 | 
				
			||||||
 | 
								// 使わないことになったストリームはしっかり取り壊す
 | 
				
			||||||
 | 
								data.destroy();
 | 
				
			||||||
 | 
								return fs.createReadStream(`${__dirname}/assets/thumbnail-not-available.png`);
 | 
				
			||||||
 | 
							// 画像であれば
 | 
				
			||||||
 | 
							} else if (/^image\/.*$/.test(type) || type == 'application/xml') {
 | 
				
			||||||
			// 0フレーム目を送る
 | 
								// 0フレーム目を送る
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
				return gm(data).selectFrame(0).stream();
 | 
									return gm(data).selectFrame(0).stream();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue