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

feat: add format and quality parameters toDataURL function #2431

Open
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

bohdanprog
Copy link
Member

@bohdanprog bohdanprog commented Aug 28, 2024

Summary

Feature #1588
Introduce new parameters, format, and quality, for the toDataURL function.

Allow users to select the compressed format (defaulting to PNG or JPEG) in the toDataURL function. Additionally, include a new parameter called quality for the JPEG format.
Created a new type, ToDataUrlOptions, and exported it externally.

The data structure appears as follows:

  const optionsWithJPEGFormat: ToDataUrlOptions = {
    format: 'jpeg',
    width,
    height,
    quality: 100,
  };
  const optionsWithPNGFormat: ToDataUrlOptions = {
    format: 'png',
    width,
    height,
  };

Test Plan

What's required for testing (prerequisites)?

What are the steps to reproduce (after prerequisites)?

Compatibility

OS Implemented
iOS
MacOS
Android
Web

Checklist

  • I have tested this on a device and a simulator
  • I added documentation in README.md
  • I updated the typed files (typescript)

@bohdanprog bohdanprog changed the title feat: add format and quality in toDataURL function feat: add format and quality parameters toDataURL function Aug 28, 2024
@bohdanprog bohdanprog requested a review from jakex7 August 29, 2024 10:02
@bohdanprog bohdanprog self-assigned this Aug 29, 2024
src/elements.web.ts Outdated Show resolved Hide resolved
apple/Elements/RNSVGSvgView.mm Outdated Show resolved Hide resolved
apps/test-examples/src/Test2233.tsx Outdated Show resolved Hide resolved
android/src/main/java/com/horcrux/svg/SvgView.java Outdated Show resolved Hide resolved
apple/Elements/RNSVGSvgView.h Outdated Show resolved Hide resolved
src/elements.web.ts Outdated Show resolved Hide resolved
src/elements.web.ts Outdated Show resolved Hide resolved
src/elements/Svg.tsx Outdated Show resolved Hide resolved
src/elements/Svg.tsx Outdated Show resolved Hide resolved
src/elements/Svg.tsx Outdated Show resolved Hide resolved
@bohdanprog bohdanprog requested a review from jakex7 September 3, 2024 12:09
@bohdanprog bohdanprog requested a review from jakex7 September 9, 2024 07:59
Copy link
Member

@jakex7 jakex7 left a comment

Choose a reason for hiding this comment

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

A few more, rest looks good to me.

src/elements/Svg.tsx Outdated Show resolved Hide resolved
src/elements/Svg.tsx Outdated Show resolved Hide resolved
android/src/main/java/com/horcrux/svg/SvgViewModule.java Outdated Show resolved Hide resolved
@bohdanprog bohdanprog requested a review from jakex7 September 20, 2024 13:49
src/elements/Svg.tsx Outdated Show resolved Hide resolved
src/elements.web.ts Outdated Show resolved Hide resolved
apps/examples/src/examples/Svg.tsx Outdated Show resolved Hide resolved
Comment on lines 118 to 120
* @deprecated use size property instead
* @param callback
* @param options as { size: { width: number, height: number }, format: 'jpeg' | 'png', quality?:1 }
Copy link
Member

Choose a reason for hiding this comment

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

https://jsdoc.app/tags-callback
callback should be typed

https://jsdoc.app/tags-param

https://jsdoc.app/tags-type
quality is not an explicit 1 value but rather a number in range {0, 1}

Copy link
Member Author

@bohdanprog bohdanprog Sep 24, 2024

Choose a reason for hiding this comment

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

updated JSdoc, let me know if it's good enough for us.

android/src/main/java/com/horcrux/svg/SvgView.java Outdated Show resolved Hide resolved
@bohdanprog bohdanprog requested a review from jakex7 September 24, 2024 13:10
src/elements/Svg.tsx Outdated Show resolved Hide resolved
src/elements/Svg.tsx Outdated Show resolved Hide resolved
src/elements/Svg.tsx Outdated Show resolved Hide resolved
src/elements/Svg.tsx Show resolved Hide resolved
src/elements/Svg.tsx Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants