naseemakhtar994 / MediaResizer

Resizeing image / video with very small effort written in Kotlin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MediaResizer CircleCI

Kotlin GitHub license

Resizeing image / video with very small effort written in Kotlin.

Minimum API Level is 18(Android 4.3)

It support...

  • Image Resizing with keeping Aspect Ratio
  • Video Resizing with Hardware-level (using android-transcoder)
    • Encoding in 720p
    • Encoding in 480p
    • Encoding in 960x540
    • Can be set value of Bitrate of Video, Bitrate of Audio, Channel of Audio
  • Resizing media with pre-well-made builder
  • 100% Java Interop Library, it can use with Java within Kotlin-plugin integrated project

Usages

rootProject/build.gradle

allprojects {
    repositories {
	    maven { url 'https://jitpack.io' }
    }
}

app/build.gradle

dependencies {
    implementation 'com.github.WindSekirun:MediaResizer:1.0.0'
}

Initialization

For use .setScanRequest(ScanRequest.TRUE), Please add this statement in your Application class.

Kotlin

MediaResizerGlobal.initializeApplication(this)

Java

MediaResizerGlobal.initializeApplication(this);

Resizing Image

MediaResizer support Image Resizing with keeping Aspect Ratio of picture.

Kotlin

val resizeOption = ImageResizeOption.Builder()
                .setImageProcessMode(ImageMode.ResizeAndCompress)
                .setImageResolution(1280, 720)
                .setBitmapFilter(false)
                .setCompressFormat(Bitmap.CompressFormat.JPEG)
                .setCompressQuality(75)
                .setScanRequest(ScanRequest.TRUE)
                .build()
        
val option = ResizeOption.Builder()
                .setMediaType(MediaType.IMAGE)
                .setImageResizeOption(resizeOption)
                .setTargetPath(path)
                .setOutputPath(imageFile.absolutePath)
                .setCallback({ code, output ->
                    txtStatus.text = displayImageResult(code, path, output)
                    progress.dismiss()
                })
                .build()

MediaResizer.process(option)

Java

ImageResizeOption resizeOption = new ImageResizeOption.Builder()
                .setImageProcessMode(ImageMode.ResizeAndCompress)
                .setImageResolution(1280, 720)
                .setBitmapFilter(false)
                .setCompressFormat(Bitmap.CompressFormat.JPEG)
                .setCompressQuality(75)
                .setScanRequest(ScanRequest.TRUE)
                .build();

ResizeOption option = new ResizeOption.Builder()
                .setMediaType(MediaType.IMAGE)
                .setImageResizeOption(resizeOption)
                .setTargetPath(path)
                .setOutputPath(imageFile.getAbsolutePath())
                .setCallback((code, output) -> {
                    txtStatus.setText(ResultBuilder.displayImageResult(code, path, output));
                    progress.dismiss();
                }).build();

MediaResizer.process(option);

Resizing Video

MediaResizer support Video Resizing with Hardware-level using android-transcoder

Video can be resizing when video has 16:9 ratio, see android-transcoder #40 comment

Kotlin

val resizeOption = VideoResizeOption.Builder()
                .setVideoResolutionType(VideoResolutionType.AS720)
                .setVideoBitrate(1000 * 1000)
                .setAudioBitrate(128 * 1000)
                .setAudioChannel(1)
                .setScanRequest(ScanRequest.TRUE)
                .build()

val option = ResizeOption.Builder()
                .setMediaType(MediaType.VIDEO)
                .setVideoResizeOption(resizeOption)
                .setTargetPath(path)
                .setOutputPath(imageFile.absolutePath)
                .setCallback({ code, output ->
                    txtStatus.text = displayVideoResult(code, path, output)
                    progress.dismiss()
                })
                .build()

MediaResizer.process(option)

Java

VideoResizeOption resizeOption = new VideoResizeOption.Builder()
                .setVideoResolutionType(VideoResolutionType.AS720)
                .setVideoBitrate(1000 * 1000)
                .setAudioBitrate(128 * 1000)
                .setAudioChannel(1)
                .setScanRequest(ScanRequest.TRUE)
                .build();

ResizeOption option = new ResizeOption.Builder()
                .setMediaType(MediaType.VIDEO)
                .setVideoResizeOption(resizeOption)
                .setTargetPath(path)
                .setOutputPath(imageFile.getAbsolutePath())
                .setCallback((code, output) -> {
                    txtStatus.setText(ResultBuilder.displayVideoResult(code, path, output));
                    progress.dismiss();
                }).build();

MediaResizer.process(option);

Sample

You can use sample of MediaResizer, APK is here

Third-party libraries

MediaResizer use Third-parth libraries for development.

for details, see third-party.md

License

Copyright 2017 WindSekirun (DongGil, Seo)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Resizeing image / video with very small effort written in Kotlin.

License:Apache License 2.0


Languages

Language:Kotlin 100.0%