Skip to content

Commit

Permalink
feat: add bmp support for analyze page (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
stew-ro authored Oct 31, 2020
1 parent b0404c6 commit 3485d33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion public/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def getArguments(argv):

for opt, arg in opts:
if opt == '-t':
if arg not in ('application/pdf', 'image/jpeg', 'image/png', 'image/tiff'):
if arg not in ('application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'image/bmp'):
print('Type ' + file_type + ' not supported')
sys.exit()
else:
Expand Down Expand Up @@ -131,6 +131,8 @@ def inferrType(input_file):
return 'application/pdf'
elif file_extension == '.jpeg':
return 'image/jpeg'
elif file_extension == '.bmp':
return 'image/bmp'
elif file_extension == '.png':
return 'image/png'
elif file_extension == '.tiff':
Expand Down
9 changes: 5 additions & 4 deletions src/react/components/pages/predict/predictPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
<input
aria-hidden="true"
type="file"
accept="application/pdf, image/jpeg, image/png, image/tiff"
accept="application/pdf, image/jpeg, image/png, image/tiff, image/bmp"
id="hiddenInputFile"
ref={this.fileInput}
onChange={this.handleFileChange}
Expand Down Expand Up @@ -493,7 +493,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre

private getFileFromURL = () => {
this.setState({ isFetching: true });
fetch(this.state.inputedFileURL, { headers: { Accept: "application/pdf, image/jpeg, image/png, image/tiff" } })
fetch(this.state.inputedFileURL, { headers: { Accept: "application/pdf, image/jpeg, image/png, image/tiff, image/bmp" } })
.then((response) => {
if (!response.ok) {
this.setState({
Expand All @@ -506,7 +506,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
return;
}
const contentType = response.headers.get("Content-Type");
if (!["application/pdf", "image/jpeg", "image/png", "image/tiff"].includes(contentType)) {
if (!["application/pdf", "image/jpeg", "image/png", "image/tiff", "image/bmp"].includes(contentType)) {
this.setState({
isFetching: false,
shouldShowAlert: true,
Expand Down Expand Up @@ -857,6 +857,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
switch (file.type) {
case "image/jpeg":
case "image/png":
case "image/bmp":
this.loadImageFile(file);
break;

Expand All @@ -874,7 +875,7 @@ export default class PredictPage extends React.Component<IPredictPageProps, IPre
imageUri: "",
shouldShowAlert: true,
alertTitle: "Not supported file type",
alertMessage: "Sorry, we currently only support JPG/PNG/PDF files.",
alertMessage: "Sorry, we currently only support JPG/PNG/PDF/BMP files.",
});
break;
}
Expand Down

0 comments on commit 3485d33

Please sign in to comment.