initml / clipdrop-api-samples Goto Github PK
View Code? Open in Web Editor NEWPublic samples using the ClipDrop API
Home Page: https://clipdrop.co/apis
License: Apache License 2.0
Public samples using the ClipDrop API
Home Page: https://clipdrop.co/apis
License: Apache License 2.0
hey ` i have seen the demo on website.
but in React ` we can't put the key in the frontend code so i use the express to post the form data image to your api
and i get a image of binary from the api`` and how i can tranform this format to image in the React?
I follow the operation method in the readme file, the result is an error, how to deal with this
hi
env:python 3.9
usage:
import requests
r = requests.post('https://clipdrop-api.co/sketch-to-image/v1/sketch-to-image',
files = {
'image_file': ('owl-sketch.jpg', image_file_object, 'image/jpeg'),
},
data = { 'prompt': 'an owl on a branch, cinematic' },
headers = { 'x-api-key': 'YOUR_API_KEY'}
)
if (r.ok):
# r.content contains the bytes of the returned image
else:
r.raise_for_status()
retrun error message :
The request multipart form is malformed: One of the files in the multipart form is not expected
Please help me find out why there is an error. I'm looking forward to your response
Hi Team,
I am currently using the ClipDrop APIs in my Android application, and I am facing issues with processing the image bytes I receive in the response. I have tried various methods including decoding the bytes into a bitmap and downloading the image via InputStream, but none of them have been successful in generating a usable output image.
When attempting to decode the image bytes into a bitmap using the following code snippet:
val imageInputStream = it.value.body()?.byteStream()
val imageBytes = imageInputStream?.readBytes()
val bitmapImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size, null)
The bitmapImage is resulting in null.
Similarly, when I download the image using an InputStream and save it, the downloaded image is corrupted and not viewable on the device.
private fun saveImageAndPreviewOutput(inputStream: InputStream) {
try {
val directory = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "photoLens")
if (!directory.exists()) {
directory.mkdirs()
}
val imageFile = File(directory, "${getUuid()}.png")
FileOutputStream(imageFile).use { output ->
inputStream.copyTo(output)
}
viewModel.outputImagePath = imageFile.toString()
val bundle = Bundle()
outputImageFragment.arguments = bundle
val transaction =
requireActivity().supportFragmentManager.beginTransaction()
.addToBackStack("OutputImageFragment")
.add(R.id.flCameraFragment, outputImageFragment)
transaction.commit()
} finally {
inputStream.close()
}
}
The downloaded image is not opening on the device, and it seems to be corrupted.
Could you please assist me in identifying and resolving the issue? I have attached a sample of the downloaded image for reference.
I have followed the example provided on the GitHub repository for the Android integration, but I am encountering the same issue there as well.
Thanks and regards,
Gourav
+91-9625508164
[email protected]
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.