7 ms·
Tried a standard input tag with the proper accept attribute <input type="file" accept="image/jpeg,image/png" /> Selected a HEIC file from Photos in Safari,
by oefrha 6y ago
Tried a standard input tag with the proper accept attribute
<input type="file" accept="image/jpeg,image/png" />
Selected a HEIC file from Photos in Safari, the selected image was automatically converted to JPEG.
Ten bucks says College Board programmer(s) failed to do the most basic and standard filtering.
Edit: Like a sibling comment said, the accept attribute actually isn't necessary; even PNG images (e.g. screenshots) from Photos are converted to JPEG automatically. This is true on both macOS and iOS Safari (latest). To be clear, on macOS you need to select from Photos instead of the filesystem for this to take effect.
In case anyone's interested, source code you can use to test for yourself (a Flask app):
app.py:
import flask
app = flask.Flask(__name__)
@app.route("/", methods=["GET", "POST"])
def index():
if flask.request.method == "POST":
image = flask.request.files["image"]
return f"uploaded {image.filename!r} ({image.mimetype})"
return flask.render_template("index.html")
templates/index.html:
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<form method="post" enctype="multipart/form-data">
<input name="image" type="file" required />
<input type="submit" />
</form>
</body>
</html>
- diebeforei485 6y agoIs this the case on both Desktop and Mobile Safari?
- oefrha 6y agoYes, see edit.
- winter_blue 6y agoWow, I didn't know browsers even supported automatic image format conversion (this is pretty impressive IMO). Terrible that their programmers didn't specify that tag attribute.
- dave5104 6y agoI don't believe that's what's happening here. The accept attribute just filters what files show up in the file picker. And iOS devices will take an extra step, and on the operating system side convert HEIC files to JPEG.
- arijun 6y agoThanks for that explanation, I was wondering how it worked.
- zhengyi13 6y ago"Be strict in what you send; be liberal in what you accept" seems a relevant maxim here, but I wonder if it's reasonable to assume given the utter ubiquity of PNG and JPEG that of course that's what other people would be using?
- oefrha 6y agoSure, and turns out you don't even need the accept attribute (see edit). They're doing something funny.
- adrianmonk 6y agoIf you're going to make an assumption, that one is definitely understandable. However, taking a step back, you should have enough representative test cases (QA snaps a photo with iPhones, tries to upload) that whether assumptions are reasonable doesn't enter into it because you aren't making them.
- dragontamer 6y ago> Ten bucks says College Board programmer(s) failed to do the most basic and standard filtering. Why is it a failure of the college board to put "accept="image/jpeg"", instead of iOS which failed to default to the more standardized jpeg format when HEIC was not specified? HEIC is a newer format which fewer systems support. iOS / Safari should default to JPEG in this case.
- bjtitus 6y agoThe comment was edited to show that iOS does in fact do this. But even if it did send HEIC, if you're going to fail to handle "any" format, then you better specify the one you can handle. By the same token, why shouldn't my computer convert every .docx to PDF, or some other "more universal" format? Instead of specifying the requirement programmatically, they spent their time sending out tweets and writing help docs.
- nitrogen 6y agoWhen was the accept attribute added to the input tag?
- bchociej 6y agoI was surprised by this, but at least as early as September 2008: https://github.com/whatwg/html/commit/c67bb312ac44737c6c175b16a7161e06a269c680 https://github.com/whatwg/html/commit/c67bb312ac44737c6c175b...
- derefr 6y ago> Instead of specifying the requirement programmatically, they spent their time sending out tweets and writing help docs. Point of order: separate people, with separate/independent/concurrent job responsibilities. It very likely wasn't the programmers tweeting and writing docs. (Heck, I expect that the College Board doesn't even retain any full-time programmers, only contracts with firms for projects.)
- 6y ago
- oefrha 6y agoTurns out I overlooked some details in the article. Some students (after the issue was known) airdropped photos to their computers and attempted to rename .heic to .png/.jpeg to bypass the extension check (who would have guessed extensions don't have to correspond to file types), they went through but were rejected a day later. The article isn't clear on what exactly was happening before, but I suppose students were trying to submit airdropped .heic directly? In any case, sounds like absolutely horrid QA and communications of what's accepted (and of course, very bad idea not supporting the format in the first place when half your test takers are taking pictures in that format). (A bit more context on my original comment: I thought they had some working system where test takers could upload photos directly from their phones — e.g., scan a QR code to open a page with a unique ID with an image upload form. Turns out that's too much to ask; their process is "get the image from your camera to your test-taking device whichever way you can think of, not our problem." Not surprisingly that's not a very foolproof process.)
- frei 6y agoIf they were submitted in time, but then rejected a day later, it seems like those cases can be resolved by some manual work by collegeboard to convert them