-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix drop image rotate wrong #2322
Conversation
Fix drag-drop image rotate wrong, as Jordan Thornquest mentioned in slack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my inline feedback..
Also: please add documentation and tests!
if (!fs.existsSync(sourceFilePath)) { | ||
reject('source file does not exist') | ||
const isBase64 = typeof sourceFilePath === 'object' && sourceFilePath.type === 'base64' | ||
if (!fs.existsSync(sourceFilePath) && !isBase64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you reject images that are not base64? e.g. i might drag&drop a pdf. Are all files always base64?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if the file not exists and the file is not a base64, reject.
In additional, I think you should add return
before reject
, the code should not run through if the file not exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but i mean what happens if you drop a PDF for example. Is that still possible with your changes? Or will it be rejected because it is not bas64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch does nothing for other file. It will work same as before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. And why don't you use something like this library instead of implementing it yourself? (tbh: first google result) https://www.npmjs.com/package/fix-orientation ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has many dependencies, maybe we don't need to import so many code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @ehhc. This feature looks good to have. But I think it should not be included in the code base of boostnote. It is almost impossible to maintain...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we make a npm module for this? And, I think we need some test for this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll do it some days later.
@@ -12,6 +12,82 @@ const STORAGE_FOLDER_PLACEHOLDER = ':storage' | |||
const DESTINATION_FOLDER = 'attachments' | |||
const PATH_SEPARATORS = escapeStringRegexp(path.posix.sep) + escapeStringRegexp(path.win32.sep) | |||
|
|||
function getImage (file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no documentation at all.
Nor are there any tests i see..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will add it later
}) | ||
} | ||
|
||
function getOrientation (file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it seems like this method does a lot of black magic.. what are all the constants about? I have no idea how this method works, what it does and what it returns..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add comments later.
}) | ||
} | ||
|
||
function fixRotate (file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it "fixes" the "wrong" rotation? I don't understand what might be wrong with it since i cannot reproduce the problem..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just like this, https://stackoverflow.com/questions/10600613/ios-image-orientation-has-strange-behavior
This is a demo image.
@ehhc comments added. |
I cannot replicate the issue. I am on 0.11.9.1 in Ubuntu 16.04 |
ok, I see |
Fix drag-drop image rotate wrong, as Jordan Thornquest mentioned in slack