Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
cog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
If you have an issue with any of our projects. feel free to register.
Open sidebar
Christopher Snowhill
cog
Commits
e16d4e8a
Commit
e16d4e8a
authored
Jan 07, 2021
by
Dmitry Nevedomsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save artwork to jpg instead of png to reduce size.
parent
bd4e64c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
Application/PlaybackEventController.m
Application/PlaybackEventController.m
+12
-7
No files found.
Application/PlaybackEventController.m
View file @
e16d4e8a
...
...
@@ -177,26 +177,31 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
if
([
defaults
boolForKey
:
@"notifications.show-album-art"
]
&&
[
pe
albumArtInternal
])
{
NSError
*
error
=
nil
;
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
NSString
*
tmpSubFolderName
=
[
NSProcessInfo
.
processInfo
globallyUniqueString
];
NSURL
*
tmpSubFolderURL
=
[[
NSURL
fileURLWithPath
:
NSTemporaryDirectory
()]
URLByAppendingPathComponent:
tmpSubFolderName
isDirectory
:
true
];
URLByAppendingPathComponent:
@"cog-artworks-cache"
isDirectory
:
true
];
if
([
fileManager
createDirectoryAtPath
:[
tmpSubFolderURL
path
]
withIntermediateDirectories:
true
attributes:
nil
error:
&
error
])
{
NSURL
*
fileURL
=
[
tmpSubFolderURL
URLByAppendingPathComponent
:
@"art.png"
];
NSString
*
tmpFileName
=
[[
NSProcessInfo
.
processInfo
globallyUniqueString
]
stringByAppendingString
:
@".jpg"
];
NSURL
*
fileURL
=
[
tmpSubFolderURL
URLByAppendingPathComponent
:
tmpFileName
];
NSImage
*
image
=
[
pe
albumArt
];
CGImageRef
cgRef
=
[
image
CGImageForProposedRect
:
NULL
context
:
nil
hints
:
nil
];
NSBitmapImageRep
*
newRep
=
[[
NSBitmapImageRep
alloc
]
initWithCGImage
:
cgRef
];
[
newRep
setSize
:[
image
size
]];
NSData
*
pngData
=
[
newRep
representationUsingType
:
NSBitmapImageFileTypePNG
properties
:@{
}];
[
pn
gData
writeToURL
:
fileURL
atomically
:
YES
];
NSData
*
jpgData
=
[
newRep
representationUsingType
:
NSBitmapImageFileTypeJPEG
properties:
@{
NSImageCompressionFactor
:
@0.5f
}];
[
jp
gData
writeToURL
:
fileURL
atomically
:
YES
];
UNNotificationAttachment
*
icon
=
[
UNNotificationAttachment
attachmentWithIdentifier
:
@"art"
URL:
fileURL
options:
nil
error:
&
error
];
content
.
attachments
=
@[
icon
];
if
(
error
)
{
// We have size limit of 10MB per image attachment.
NSLog
(
@"%@"
,
error
.
localizedDescription
);
}
else
{
content
.
attachments
=
@[
icon
];
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment