@xuda.io/ai_module 1.1.4316 → 1.1.4317

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +36 -36
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -6858,49 +6858,49 @@ const return_image_blob_from_downloaded_image = async function (url) {
6858
6858
 
6859
6859
  return { is_transparent, image_blob: new Blob([buffer], { type: 'image/png' }) };
6860
6860
  }
6861
- try {
6862
- if (!url) {
6863
- throw new Error('No URL provided in request');
6864
- }
6861
+ // try {
6862
+ if (!url) {
6863
+ throw new Error('No URL provided in request');
6864
+ }
6865
6865
 
6866
- // 3. Download the image to a Buffer
6867
- const res = await fetch(url);
6868
- if (!res.ok) {
6869
- throw new Error(`Failed to fetch image URL: ${res.status} ${res.statusText}`);
6870
- }
6866
+ // 3. Download the image to a Buffer
6867
+ const res = await fetch(url);
6868
+ if (!res.ok) {
6869
+ throw new Error(`Failed to fetch image URL: ${res.status} ${res.statusText}`);
6870
+ }
6871
6871
 
6872
- const arrayBuffer = await res.arrayBuffer();
6873
- const imageBuffer = Buffer.from(arrayBuffer);
6872
+ const arrayBuffer = await res.arrayBuffer();
6873
+ const imageBuffer = Buffer.from(arrayBuffer);
6874
6874
 
6875
- const tempDir = os.tmpdir();
6876
- const uniqueId = Date.now() + '_' + Math.random().toString(36).substring(7);
6875
+ const tempDir = os.tmpdir();
6876
+ const uniqueId = Date.now() + '_' + Math.random().toString(36).substring(7);
6877
6877
 
6878
- const inputExt = path.extname(url) || '.jpg';
6879
- const tempInputPath = path.join(tempDir, `input_${uniqueId}${inputExt}`);
6880
- const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`); // Output is always PNG (transparent)
6878
+ const inputExt = path.extname(url) || '.jpg';
6879
+ const tempInputPath = path.join(tempDir, `input_${uniqueId}${inputExt}`);
6880
+ const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`); // Output is always PNG (transparent)
6881
6881
 
6882
- // 5. Write the downloaded image to disk
6883
- fs.writeFileSync(tempInputPath, imageBuffer);
6884
- /////////////////////////////////
6882
+ // 5. Write the downloaded image to disk
6883
+ fs.writeFileSync(tempInputPath, imageBuffer);
6884
+ /////////////////////////////////
6885
6885
 
6886
- const imageFiles = [tempInputPath];
6886
+ const imageFiles = [tempInputPath];
6887
6887
 
6888
- const images = await Promise.all(
6889
- imageFiles.map(async (filePath) => {
6890
- const img_ret = await imageToPngBlob(filePath);
6891
- const blob = img_ret.image_blob;
6888
+ const images = await Promise.all(
6889
+ imageFiles.map(async (filePath) => {
6890
+ const img_ret = await imageToPngBlob(filePath);
6891
+ const blob = img_ret.image_blob;
6892
6892
 
6893
- // OpenAI expects a filename for logging/debugging
6894
- const filename = path.basename(filePath, path.extname(filePath)) + '.png';
6895
- blob.name = filename; // Optional but helpful
6896
- // @ts-ignore – name is allowed in Node 20+
6897
- blob.lastModified = Date.now();
6893
+ // OpenAI expects a filename for logging/debugging
6894
+ const filename = path.basename(filePath, path.extname(filePath)) + '.png';
6895
+ blob.name = filename; // Optional but helpful
6896
+ // @ts-ignore – name is allowed in Node 20+
6897
+ blob.lastModified = Date.now();
6898
6898
 
6899
- return { is_transparent: img_ret.is_transparent, image_blob: blob };
6900
- }),
6901
- );
6902
- return { image_blob: images[0].image_blob, is_transparent: images[0].is_transparent, tempOutputPath };
6903
- } catch (err) {
6904
- console.error(err);
6905
- }
6899
+ return { is_transparent: img_ret.is_transparent, image_blob: blob };
6900
+ }),
6901
+ );
6902
+ return { image_blob: images[0].image_blob, is_transparent: images[0].is_transparent, tempOutputPath };
6903
+ // } catch (err) {
6904
+ // console.error(err);
6905
+ // }
6906
6906
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4316",
3
+ "version": "1.1.4317",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",