imgix / imgix-swift Goto Github PK
View Code? Open in Web Editor NEWA Swift client library for generating URLs with imgix
Home Page: https://www.imgix.com
License: BSD 2-Clause "Simplified" License
A Swift client library for generating URLs with imgix
Home Page: https://www.imgix.com
License: BSD 2-Clause "Simplified" License
It would be convenient if there was a way to build an imgix formatted image from an nsurl.
UseCase:
ImgixClient
which could somehow take this in as a NSURL
or NSURLComponents
object, along with an imgix extra parameters formatted dictionary, and then build the final url preserving the original information from the passed in information.example:
imgixClient.reconstruct(url:NSURL, params:[String:AnyObject]) -> NSURL?
I have some code which does this in our project, happy to open a PR if you think it's a useful feature.
Description:
When using the Swift Library to construct imgix URLs, you must include a host to initialize the imgix client. An image of the code block is included below.
https://assetmanager.imgix.net/Testing-%F0%9F%98%83.png
The suggestion would be to allow these URLs to be built using an input URL. Similar to what is being used in our current URL reconstruction library.
https://assetmanager.imgix.net/URlRecon.png
Problem:
Currently, Grailed is trying to use our library to build the URLs they will be listing in their IOS app using the Swift library. They are building these URLs using custom domains. So when building the host URL they would rather the client builder use the host that's already in the URL.
Suggested Solution:
To allow the URLs to accept a no-host input and grab the host name from the input URL.
Describe alternatives you've considered
For now, they can just use the imgixClient instance or use the URL reconstructor to ensure they get the correct URL.
Describe the feature
If the buildUrl
function builds a Web Proxy URL with a pre-encoded URL, the URL will be double encoded. This returns a 400
error in the Rendering API.
To Reproduce
secureUrlToken
):let signedClient = ImgixClient.init(
host: "imgix-web-proxy-test-source.imgix.net",
secureUrlToken: "EHFQXiZhxP4wA2c4"
)
// This will return a `400` error
signedClient.buildUrl("http%3A%2F%2Fassets.imgix.net%2Fexamples%2Fcat.jpg") // => https://imgix-library-secure-test-source.imgix.net/http%253A%252F%252Fassets.imgix.net%252Fexamples%252Fcat.jpg?s=5751ef13a5ca325fab9c4038b080cd80
I am using both Objective C and Swift languages in my project and have created a bridging header. My project had been working from a year but upon installing Imgix pod it's giving me build error.
Error: In an objective c file -> projectName-Swift.h file not found.
Can you please help me?
I'm getting the following error when building the latest release with carthage:
Module file's minimum deployment target is ios9.3 v9.3.
My guess is that this occurs because the minimum deployment target for my app is iOS 9.0 which is lower than the deployment target for the imgix-swift sdk(9.3). Is it possible to have the deployment target lowered for imgix-swift?
I'm trying to use the Imgix-Swift library to generate signed imgix URLs in an objective-c iPhone application.
Unsigned, my URL looks like this:
https://host/94BAB140-493B-453F-97CE-739C2685B88A.jpg?or=1&w=488&h=488&fit=max&auto=redeye&rect=1626,652,848,848
When I try to build a signed URL with ImgixClient -buildURL:params:
, I get this
https://host/94BAB140-493B-453F-97CE-739C2685B88A.jpg?ixlib=swift-0.1.2&h=488&rect=1626%2C652%2C848%2C848&or=1&w=488&auto=redeye&fit=max&s=f3a7f97bfa05a0fe584c5151fe69e87a
This results in a 401.
If instead, I use the base-64 parameters, I get this:
https://host/94BAB140-493B-453F-97CE-739C2685B88A.jpg?auto64=cmVkZXll&rect64=MTYyNiw2NTIsODQ4LDg0OA&ixlib=swift-0.1.2&w64=NDg4&or64=MQ&fit64=bWF4&h64=NDg4&s=871421f2c35975e750211f222037c58e
This works just fine.
I adjusted my input, and narrowed the problematic parameter down to rect
, which has a comma-separated value.
I am using imgix and it crash for following url.
"https://imgix.net/live/menu_items/photos/1291/e1eefb34a6b7c415873a0fdd31969af86704f0d/ج_مع_الراب_الرومى.jpg"
it crashes while buildURL is called.
We got the crash report below. Any ideas what could've caused it?
Crashed: com.apple.main-thread
SIGABRT ABORT 0x0000000189f72014
Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x189f72014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x18a03a450 pthread_kill + 112
2 libsystem_c.dylib 0x189ee63e0 abort + 140
3 libsystem_malloc.dylib 0x189fb6a38 _nano_vet_and_size_of_live + 330
4 libsystem_malloc.dylib 0x189fb7db8 nano_free + 220
5 CoreFoundation 0x18af29060 __CFCharacterSetDeallocate + 108
6 CoreFoundation 0x18af51a74 _CFRelease + 216
7 CoreFoundation 0x18af290a0 __CFCharacterSetDeallocate + 172
8 CoreFoundation 0x18af51a74 _CFRelease + 216
9 libswiftFoundation.dylib 0x100acd914 _TFE10FoundationSS50stringByAddingPercentEncodingWithAllowedCharactersfCSo14NSCharacterSetGSqSS_ + 136
10 ImgixSwift 0x1003a08cc String.ixEncodeUriComponent() -> String (String+ImgixSwift.swift:34)
11 ImgixSwift 0x10039f958 specialized ImgixClient.buildUrl(String, params : NSDictionary) -> NSURL (ImgixClient.swift:70)
12 ImgixSwift 0x10039dd88 ImgixClient.buildUrl(String, params : NSDictionary) -> NSURL (ImgixClient.swift:39)
13 shoptanga 0x10003a4e4 specialized static ImageHelper.resizedImageURL(String, width : CGFloat, height : CGFloat)
This is the calling code:
import Foundation
import UIKit
import ImgixSwift
class ImageHelper {
class func resizedImageURL(sourceURL: String, width:CGFloat, height:CGFloat) -> NSURL {
let client = ImgixClient.init(host: "tanga1.imgix.net", secureUrlToken: "XXXXXXX")
return client.buildUrl(
sourceURL,
params: [
"width": width,
"height": height,
"format": "auto",
"lossless": "true",
"cs": "strip"])
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.