Skip to content
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

rotate module #1218

Merged
merged 11 commits into from
Sep 24, 2019
Merged

rotate module #1218

merged 11 commits into from
Sep 24, 2019

Conversation

keshav234156
Copy link
Member

@keshav234156 keshav234156 commented Aug 20, 2019

Fixes #1137
this PR fixes the clipping of image while using rotate module
Screenshot from 2019-08-20 13-21-01

image at 30
download (17)

image at 90
download (18)

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with npm test
  • code is in uniquely-named feature branch and has no merge conflicts
  • PR is descriptively titled
  • ask @publiclab/is-reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

@codecov
Copy link

codecov bot commented Aug 20, 2019

Codecov Report

Merging #1218 into main will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1218      +/-   ##
==========================================
- Coverage   32.07%   32.05%   -0.02%     
==========================================
  Files         107      107              
  Lines        1986     1987       +1     
  Branches      297      296       -1     
==========================================
  Hits          637      637              
- Misses       1349     1350       +1
Impacted Files Coverage Δ
src/modules/Rotate/Module.js 20% <0%> (-0.84%) ⬇️

@keshav234156
Copy link
Member Author

@jywarren @harshkhandeparkar can you please guide me how to fix the issues given by codeclimate

@harshkhandeparkar
Copy link
Member

harshkhandeparkar commented Aug 20, 2019 via email

@aashna27
Copy link

aashna27 commented Aug 20, 2019 via email

@keshav234156
Copy link
Member Author

@harshkhandeparkar @jywarren can you please review the changes!!

@harshkhandeparkar
Copy link
Member

harshkhandeparkar commented Aug 20, 2019 via email

@keshav234156
Copy link
Member Author

@harshkhandeparkar can you please review if you are free

@harshkhandeparkar
Copy link
Member

harshkhandeparkar commented Aug 26, 2019 via email

Copy link
Member

@harshkhandeparkar harshkhandeparkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perfect. Only one thing. Is it possible to make the code more readable? You could start by splitting the file into two - Module.js and Rotate.js (take inspiration from other modules)
@keshav234156

@keshav234156
Copy link
Member Author

@harshkhandeparkar Splitting the file inti Module.js and Rotate.js would make the code easy to understand and i think there won't be any issue.So will make change and push it asap.

@keshav234156
Copy link
Member Author

@jywarren @harshkhandeparkar have splitted it into 2 files.please have a look

src/modules/Rotate/Module.js Show resolved Hide resolved
src/modules/Rotate/Rotate.js Outdated Show resolved Hide resolved
@harshkhandeparkar
Copy link
Member

harshkhandeparkar commented Sep 2, 2019 via email

@keshav234156
Copy link
Member Author

keshav234156 commented Sep 2, 2019

@publiclab/is-reviewers @jywarren can you please review the PR

@aashna27
Copy link

The work done is really great. Thanks. Can you document the flow so that it becomes easy to understand.

@keshav234156
Copy link
Member Author

@aashna27 have a look..

@keshav234156
Copy link
Member Author

@jywarren Have a look

@keshav234156
Copy link
Member Author

@aashna27 @jywarren can you please review this PR!!

@jywarren
Copy link
Member

Apologies, @keshav234156 i was in a week of meetings, I'm looking now! First, i'll update to sync with the latest main branch. Then will look through the code. Thanks for your patience, we're still recovering a bit from our Summer of Code wrap-up!


if (rotate_value % 360 == 0)
return pixels;
function copyPixel(x1, y1, x2, y2){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, couldn't this get extra pixels1, pixels2 parameters and then we'd have only one function instead of 2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, would do the changes to make a 1 function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jywarren any other changes that are required??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jywarren Had done the changes to make a single function instead of 2

var bitmap = new imagejs.Bitmap({ width: pixels1.shape[0], height: pixels1.shape[1] });
bitmap._data.data = pixels1.data;

var rotated = bitmap.rotate({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so why do we need to do so much pixel copying and rotation math if we are still using the Imagejs Bitmap function to perform the rotation? Perhaps some comments would help clarify what's going on here? Sorry, it's just a little hard to follow! Thanks for your help, i love the output, just being sure I understand what's happening inside as well :-)

Copy link
Member Author

@keshav234156 keshav234156 Sep 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

earlier if we use bitmap on original image then it cropped some of the image.to solve this i have put the image on a larger frame ie is square so that there is no problem of clipping,rotated the larger frame image with the help of imagejs rotation function and then extra white is cropped according to to final image dimensions after rotation

Copy link
Member Author

@keshav234156 keshav234156 Sep 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pixel1 is a square frame that contain original image at it's centre.then we rotated the pixel1 with help of imagejs,at the last we copied pixels from pixel1 to pixel2 so that there is no extra whitespace.

@keshav234156
Copy link
Member Author

@jywarren if there any other changes or method in your mind please let me know!!.would love to solve this issue.

@jywarren
Copy link
Member

Looks great. Thanks so much!

@jywarren jywarren merged commit 3eb741c into publiclab:main Sep 24, 2019
jywarren pushed a commit that referenced this pull request Dec 16, 2019
* this PR solves the problem of clipping of the image while rotating

* a little clipping was still present .so made the changes

* Splitted into two files

* ommitted extra declared variables

* Update Module.js

* Update Rotate.js

* Update Rotate.js
@harshkhandeparkar harshkhandeparkar added this to Done in v3.6.0 Oct 17, 2020
@harshkhandeparkar harshkhandeparkar removed this from Done in v3.6.0 Oct 17, 2020
@harshkhandeparkar harshkhandeparkar added this to Done in v3.6.0 Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v3.6.0
  
Done
Development

Successfully merging this pull request may close these issues.

Rotate module not functioning correctly
4 participants