Compare commits

..

No commits in common. "main" and "27f30e0f9d258f24a41f146ecafacc26d72a534c" have entirely different histories.

7 changed files with 357 additions and 867 deletions

View File

@ -1,19 +0,0 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: cargo_check
image: rust
commands:
- cargo check
- name: cargo_test
image: rust
commands:
- cargo test
- name: cargo_clippy
image: rust
commands:
- rustup component add clippy
- cargo clippy

10
.travis.yml Normal file
View File

@ -0,0 +1,10 @@
language: rust
rust:
- stable
- beta
- nightly
cache: cargo
matrix:
allow_failures:
- rust: nightly
fast_finish: true

1159
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package] [package]
name = "id3-image-rs" name = "id3-image-rs"
version = "0.4.2" version = "0.4.0"
authors = ["Andrew Radev <andrey.radev@gmail.com>", "Pierre Hubert <pierre.git@communiquons.org>"] authors = ["Andrew Radev <andrey.radev@gmail.com>", "Pierre Hubert <pierre.git@communiquons.org>"]
edition = "2018" edition = "2018"
description = "A tool to embed images into mp3 files (forked, updated and extended api)" description = "A tool to embed images into mp3 files (forked, updated and extended api)"
@ -12,10 +12,10 @@ keywords = [ "id3", "mp3", "images" ]
categories = [ "command-line-utilities", "filesystem", "multimedia" ] categories = [ "command-line-utilities", "filesystem", "multimedia" ]
[dependencies] [dependencies]
anyhow = "1.0.82" anyhow = "1.0.56"
id3 = "1.13.1" id3 = "1.0.2"
image = "0.25.1" image = "0.24.1"
structopt = { version = "0.3.26", default-features = false } structopt = { version = "0.3.26", default-features = false }
[dev-dependencies] [dev-dependencies]
tempfile = "3.10.1" tempfile = "3.3.0"

View File

@ -1,12 +1,4 @@
# id3-image-rs [![Build Status](https://travis-ci.org/AndrewRadev/id3-image.svg?branch=main)](https://travis-ci.org/AndrewRadev/id3-image)
[![Build Status](https://drone.communiquons.org/api/badges/pierre/id3-image-rs/status.svg)](https://drone.communiquons.org/pierre/id3-image-rs)
This project is a fork of the crate [id3_image](https://crates.io/crates/id3-image) with extended API and updated dependencies.
99.9% of the credit for this work should go to the [initial author of this crate](https://github.com/AndrewRadev).
___
This tool wraps the [rust-id3](https://github.com/jameshurst/rust-id3) library to provide an easy way to manipulate embedded cover art in an mp3 file. The embedded image usually gets picked up by music players and thumbnail generators. This tool wraps the [rust-id3](https://github.com/jameshurst/rust-id3) library to provide an easy way to manipulate embedded cover art in an mp3 file. The embedded image usually gets picked up by music players and thumbnail generators.

View File

@ -1,8 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
":automergeAll",
":enableVulnerabilityAlerts",
":ignoreUnstable"
]
}

View File

@ -17,7 +17,7 @@ use image::DynamicImage;
/// Tags get written as ID3v2.3. /// Tags get written as ID3v2.3.
/// ///
pub fn embed_image(music_filename: &Path, image_filename: &Path) -> anyhow::Result<()> { pub fn embed_image(music_filename: &Path, image_filename: &Path) -> anyhow::Result<()> {
let image = image::open(image_filename) let image = image::open(&image_filename)
.map_err(|e| anyhow!("Error reading image {:?}: {}", image_filename, e))?; .map_err(|e| anyhow!("Error reading image {:?}: {}", image_filename, e))?;
embed_image_from_memory(music_filename, &image) embed_image_from_memory(music_filename, &image)
@ -38,7 +38,7 @@ pub fn embed_image_from_memory(
let mut encoded_image_bytes = Cursor::new(Vec::new()); let mut encoded_image_bytes = Cursor::new(Vec::new());
// Unwrap: Writing to a Vec should always succeed; // Unwrap: Writing to a Vec should always succeed;
image image
.write_to(&mut encoded_image_bytes, image::ImageFormat::Jpeg) .write_to(&mut encoded_image_bytes, image::ImageOutputFormat::Jpeg(90))
.unwrap(); .unwrap();
tag.add_frame(id3::frame::Picture { tag.add_frame(id3::frame::Picture {
@ -68,7 +68,7 @@ pub fn embed_image_from_memory(
/// ///
pub fn extract_first_image(music_filename: &Path, image_filename: &Path) -> anyhow::Result<()> { pub fn extract_first_image(music_filename: &Path, image_filename: &Path) -> anyhow::Result<()> {
extract_first_image_as_img(music_filename)? extract_first_image_as_img(music_filename)?
.save(image_filename) .save(&image_filename)
.map_err(|e| anyhow!("Couldn't write image file {:?}: {}", image_filename, e)) .map_err(|e| anyhow!("Couldn't write image file {:?}: {}", image_filename, e))
} }
@ -104,7 +104,7 @@ pub fn remove_images(music_filename: &Path) -> anyhow::Result<()> {
} }
fn read_tag(path: &Path) -> anyhow::Result<id3::Tag> { fn read_tag(path: &Path) -> anyhow::Result<id3::Tag> {
id3::Tag::read_from_path(path).or_else(|e| { id3::Tag::read_from_path(&path).or_else(|e| {
eprintln!( eprintln!(
"Warning: file metadata is corrupted, trying to read partial tag: {}", "Warning: file metadata is corrupted, trying to read partial tag: {}",
path.display() path.display()