hi friend, I need your help. this my current code right here and I don't exactly know how to implement your code that is in the video. If it is possible can you say me what to change in this code to compress images like you said? thanks in advance man :) . . const photosMiddleware = multer({dest:'uploads/'}); app.post('/upload', photosMiddleware.array('photos', 100) ,(req,res)=>{ const uploadedFiles = []; for(let i = 0; i < req.files.length;i++){ const {path, originalname} = req.files[i]; const parts = originalname.split('.'); const ext = parts[parts.length-1]; const newPath = path + '.' + ext; fs.renameSync(path, newPath); uploadedFiles.push(newPath.replace('uploads\\', '')); } res.json(uploadedFiles); });
@@AdnanAfzal565 first of all, thank you for responding man. Actually, I don't get any problem in this code, however I did not get what I have to modify in order to compress image size. If you dont mind I wanna explain what is this code all about. So, I use multer and I have folder where all images that uploaded by user stands "uploads/", then I have an array where users can upload multiple images at once, then I change their name and give them new path which is newPath, then I upload to the newPath.replace('uploads\\', ''). this is all about man however I dont exactly know where i have to implement your code that you showed us. if it is possible can you make changes in my code to also compress images. And also thanks for response man:)
Thanks for this. I was looking exactly for this 👍🏼
You are welcome.
Thanks for the video, how do i mention the size of the compressed image. suppose i want it to rescue to 2MB, how do I mention that?
There is no such option. Only quality parameter can be used.
If you have already make then plz send the link
Bro can you make a video on image compressor using html,css,react and node js
For that you also need to provide the design too.
Thank you. Is there a way to select multiple images?
Yes. You can follow this:
ruclips.net/video/eHEDJBk3ie0/видео.html
Only follow the bootstrap fd part. Rest will be in Node JS.
@@AdnanAfzal565 thank you very much
@@GabrielMartinez-ez9ue You are welcome.
@@GabrielMartinez-ez9ue Can you please share the code for Multiple Images ??
@@AdnanAfzal565 Can you please share the code for Multiple Images ??
not installing the pngquant-bin and rest
Are you using latest node js version ?
@@AdnanAfzal565 yess
@@AdnanAfzal565 but i tried to follow the solution and downgrade my version but still getting the problem
What error are you having ?
@@AdnanAfzal565 please share your LinkedIn or contact number.
hi friend, I need your help. this my current code right here and I don't exactly know how to implement your code that is in the video. If it is possible can you say me what to change in this code to compress images like you said?
thanks in advance man :)
.
.
const photosMiddleware = multer({dest:'uploads/'});
app.post('/upload', photosMiddleware.array('photos', 100) ,(req,res)=>{
const uploadedFiles = [];
for(let i = 0; i < req.files.length;i++){
const {path, originalname} = req.files[i];
const parts = originalname.split('.');
const ext = parts[parts.length-1];
const newPath = path + '.' + ext;
fs.renameSync(path, newPath);
uploadedFiles.push(newPath.replace('uploads\\', ''));
}
res.json(uploadedFiles);
});
Can you kindly tell what error are you having ?
@@AdnanAfzal565 first of all, thank you for responding man. Actually, I don't get any problem in this code, however I did not get what I have to modify in order to compress image size. If you dont mind I wanna explain what is this code all about.
So, I use multer and I have folder where all images that uploaded by user stands "uploads/", then I have an array where users can upload multiple images at once, then I change their name and give them new path which is newPath, then I upload to the newPath.replace('uploads\\', ''). this is all about man however I dont exactly know where i have to implement your code that you showed us. if it is possible can you make changes in my code to also compress images. And also thanks for response man:)
@@AdnanAfzal565 I really need ur help man :-(