Arkatme
Arkatme
DDeno
Created by Arkatme on 8/5/2023 in #help
Resize image/convert on upload
Ah thank you. Got it working eventually
async function uploadAvatar(user_id: string, profileImageFile: File, storage: StorageClient) {
// Initialize ImageMagick
await initialize();

// Read the profileImageFile as a Uint8Array
const fileData: Uint8Array = new Uint8Array(await profileImageFile.arrayBuffer());

// Use ImageMagick to process the image and get the processed data as Uint8Array
const processedData: Uint8Array = ImageMagick.read(fileData, (img: IMagickImage) => {
img.resize(200, 200);

// Use the write() method to specify the output format (MagickFormat.Webp)
return img.write(MagickFormat.Webp, (data: Uint8Array) => data);
});

// Create a new File from the processed data
const processedImageFile = new File([processedData], `${user_id}.webp`, {
type: 'image/webp',
});

// Use the same code for uploading the processed image to Supabase
const filename = `public/${user_id}.webp`;
const { data, error } = await storage.from('avatars').upload(filename, processedImageFile, {
cacheControl: '3600',
upsert: false,
});

if (error) {
console.log(error);
}
}
async function uploadAvatar(user_id: string, profileImageFile: File, storage: StorageClient) {
// Initialize ImageMagick
await initialize();

// Read the profileImageFile as a Uint8Array
const fileData: Uint8Array = new Uint8Array(await profileImageFile.arrayBuffer());

// Use ImageMagick to process the image and get the processed data as Uint8Array
const processedData: Uint8Array = ImageMagick.read(fileData, (img: IMagickImage) => {
img.resize(200, 200);

// Use the write() method to specify the output format (MagickFormat.Webp)
return img.write(MagickFormat.Webp, (data: Uint8Array) => data);
});

// Create a new File from the processed data
const processedImageFile = new File([processedData], `${user_id}.webp`, {
type: 'image/webp',
});

// Use the same code for uploading the processed image to Supabase
const filename = `public/${user_id}.webp`;
const { data, error } = await storage.from('avatars').upload(filename, processedImageFile, {
cacheControl: '3600',
upsert: false,
});

if (error) {
console.log(error);
}
}
3 replies
DDeno
Created by Arkatme on 8/3/2023 in #help
What should my entry point be on Deno Deploy?
2 replies
DDeno
Created by Arkatme on 8/2/2023 in #help
Set a cookie in GET and retrieve in POST
Ended up using sessionStorage. That worked in the end.
4 replies
DDeno
Created by Arkatme on 7/30/2023 in #help
Site runs fine but vscode is filled with errors.
oh im a dumb dumb, it's cause I had the parent folder opened in vscode
8 replies
DDeno
Created by Arkatme on 7/30/2023 in #help
Site runs fine but vscode is filled with errors.
8 replies
DDeno
Created by Arkatme on 7/30/2023 in #help
Site runs fine but vscode is filled with errors.
added but still hasn't made a difference sadly
8 replies
DDeno
Created by Arkatme on 7/30/2023 in #help
Site runs fine but vscode is filled with errors.
Yes I do
8 replies