-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Implement additional ImageResources (#55)
* [feature] Implement missing ImageResources * Add tests for extra properties * Simplify readFixedPoint32Bit computation * Make DimensionUnit, ResolutionUnit part of API
- Loading branch information
Showing
10 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @webtoon/psd | ||
// Copyright 2021-present NAVER WEBTOON | ||
// MIT License | ||
|
||
import {ImageResourceBlockBase} from "./ImageResourceBlockBase"; | ||
import {ResourceType} from "./ResourceType"; | ||
|
||
export type GlobalLightResourceBlock = ImageResourceBlockBase< | ||
ResourceType.GlobalLightAltitude | ResourceType.GlobalLightAngle, | ||
number | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// @webtoon/psd | ||
// Copyright 2021-present NAVER WEBTOON | ||
// MIT License | ||
|
||
import {ImageResourceBlockBase} from "./ImageResourceBlockBase"; | ||
import {ResourceType} from "./ResourceType"; | ||
|
||
export enum ResolutionUnit { | ||
PixelsPerInch = 1, | ||
PixelsPerCM = 2, | ||
} | ||
|
||
export enum DimensionUnit { | ||
Inch = 1, | ||
CM = 2, | ||
Point = 3, // 72 points == 1 inch | ||
Pica = 4, // 6 pica == 1 inch | ||
Column = 5, | ||
} | ||
|
||
export interface ResolutionInfo { | ||
horizontal: number; | ||
horizontalUnit: ResolutionUnit; | ||
widthUnit: DimensionUnit; | ||
vertical: number; | ||
verticalUnit: ResolutionUnit; | ||
heightUnit: DimensionUnit; | ||
} | ||
export type ResolutionInfoResourceBlock = ImageResourceBlockBase< | ||
ResourceType.ResolutionInfo, | ||
ResolutionInfo | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/psd/src/sections/ImageResource/readResolutionInfo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// @webtoon/psd | ||
// Copyright 2021-present NAVER WEBTOON | ||
// MIT License | ||
|
||
import {ResolutionInfoResourceBlock} from "../../interfaces"; | ||
import {Cursor} from "../../utils"; | ||
|
||
export function readResolutionInfo( | ||
cursor: Cursor | ||
): ResolutionInfoResourceBlock["resource"] { | ||
const horizontal = cursor.readFixedPoint32bit(); | ||
const horizontalUnit = cursor.read("u16"); | ||
const widthUnit = cursor.read("u16"); | ||
|
||
const vertical = cursor.readFixedPoint32bit(); | ||
const verticalUnit = cursor.read("u16"); | ||
const heightUnit = cursor.read("u16"); | ||
|
||
return { | ||
horizontal, | ||
horizontalUnit, | ||
widthUnit, | ||
vertical, | ||
verticalUnit, | ||
heightUnit, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters