0

I am actually using a face detection (with eyes, mouth, face) library in JQuery. I have manipulated/changed many things (such as length, width, blur etc) on the pictures to see what are the most perfect settings for a picture to have a well-detected face on it. It is really easy to change property of the image in JS BUT the issue I am facing is that :

the face detection on a .jpg picture works way better than for a .png picture.

Problem 1 : the picture is uploaded using <input type="file" accept="image/*"> so maybe I have to change the extension before the picture is really uploaded on the page

Problem 2 : how to do that. I read on internet the difference between .jpg and .png but how to change it ? I know that jpg is lighter but I don't care.

To summarize: Is it possible to change the extension of a picture BEFORE it is uploaded on a webpage ?

ps: The image is loaded on Canvas, I don't know if it changes anything.

Hearner
  • 2,585
  • 2
  • 14
  • 30
  • basically you want to accept .png and jpg images in the input and want to change it when the user adds an image – Kevin Kloet Nov 01 '16 at 15:17
  • if so [this](http://stackoverflow.com/questions/4234589/validation-of-file-extension-before-uploading-file#4237161) might help you. – Kevin Kloet Nov 01 '16 at 15:21
  • 1
    I guess you mean image **format**, not (file name) _extension_. – hindmost Nov 01 '16 at 15:21
  • I don't want the user to have to change the extension of its image before uploaded it @KevinKloet I want ME to change it – Hearner Nov 01 '16 at 15:31
  • @hindmost I want the user to import a picture in my page. I put it in a canvas and activate the face detection on it. This is what I am planning to do. How can I add a button for the user to upload a image without using the – Hearner Nov 01 '16 at 15:31
  • @Hearner i never said the user needed to change the image format, you basically need to do what was in the other question but instead of returning an error you need to change the extension from .png to .jpg. – Kevin Kloet Nov 01 '16 at 15:36
  • @KevinKloet I was wondering if only changing the extension would change the image. I mean I can take any file I want a add the extension .exemple and the file extension will change. – Hearner Nov 01 '16 at 15:41
  • i suggest checking in the javascript if given file extension matches .png and just make it .jpg, if you give something a .example extension makes it an invalid file thus gives you an error when you try to load it so be strict in choosing the extensions – Kevin Kloet Nov 01 '16 at 15:52

0 Answers0